Use envman to export a new environment variable from an already existing one

As part of my workflow I need to create a new environment variable that having as value the bitrise deploy folder (aka $BITRISE_DEPLOY_DIR)

In my workflow I have defined a script step as follow:

  - script@1.1.4:
        - content: |-
            envman add --key IMAGE_DIFF_DIR --value "${BITRISE_DEPLOY_DIR}"
            echo "Snapshot failure folder: ${IMAGE_DIFF_DIR}"

The expected result would be the step printing following

Snapshot failure folder: /Users/........

Although the actual behaviour is:

Snapshot failure folder: 

It looks like the value of BITRISE_DEPLOY_DIR is empty or, more plausible, Iā€™m doing something wrong.

@iamfabiomilano move the echo line into a separate Script step.

envman by itself will not (and can not) modify the environments of the current step (process).

This also works, if you need the env var both in the current and in subsequent steps (processes):

envman add --key IMAGE_DIFF_DIR --value "${IMAGE_DIFF_DIR}"
echo "Snapshot failure folder: ${IMAGE_DIFF_DIR}"
1 Like