Skip to content

Commit

Permalink
Include env variables defined in a dependency in the step itself.
Browse files Browse the repository at this point in the history
Prior to this commit, a `dependency` defined by the `molecule.yaml` file
would not honor the values in its `env` map. Consider the following:

```yaml
dependency:
  name: shell
  command: env
  env:
    FOO: bar
```

Invoking `molecule test` would show that `FOO` is not set during the run
of this dependency. The cause was the fact that these values were never
actually passed to the `util.run_command()` invocation. This also means
`MOLECULE_EPHEMERAL_DIRECTORY` and similar `MOLECULE_*` environment
variables that are defined by the dependency's `default_env` property
were also never available to the dependency's environment.
  • Loading branch information
fabacab committed Sep 19, 2023
1 parent 01631c7 commit d2f3479
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/molecule/dependency/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def execute_with_retries(self):
exception = None

try:
util.run_command(self._sh_command, debug=self._config.debug, check=True)
util.run_command(self._sh_command, debug=self._config.debug, check=True, env=self.env)
msg = "Dependency completed successfully."
LOG.info(msg)
return
Expand All @@ -71,7 +71,7 @@ def execute_with_retries(self):
self.SLEEP += self.BACKOFF

try:
util.run_command(self._sh_command, debug=self._config.debug, check=True)
util.run_command(self._sh_command, debug=self._config.debug, check=True, env=self.env)
msg = "Dependency completed successfully."
LOG.info(msg)
return
Expand Down

0 comments on commit d2f3479

Please sign in to comment.