Skip to content

Bring back environment variables

Current situation

Environment variables exported by steps (using core.exportVariable or by appending to OPENTF_VARIABLES) are usable in following steps as documented, but only from the execution environment.

This is useful but not as expressive as it could be.

Desired outcome

The following is allowed in a workflow:

   - run: 'echo "foo=bar" >>$OPENTF_VARIABLES'
   - run: 'echo "you should not see this!"'
     if: variables.foo != 'bar'

Analysis

The specification (in its reference section) does not explicitly state this, but this is a logical expectation.

Solution

After a step is processed, the channel plugin should bring back the OPENTF_VARIABLES file, if it exists, so that the core services can process it.

The ExecutionResult event should be enhanced to bring back the defined or modified environment variables.

If the file content is invalid, an ExecutionError event is generated.

The specification should be completed to document this, so that there is no doubt it is a legitimate use case.