envman icon indicating copy to clipboard operation
envman copied to clipboard

Env Vars set using envman are not available in current step

Open DamienBitrise opened this issue 2 years ago • 5 comments

In a single script step do the following

envman add --key SOME_KEY --value 'some value'
echo $SOME_KEY

Note that the Env Var is not set

Ideally Envman would also set the env var using export so it is available in the current step

export SOME_KEY="some value"

DamienBitrise avatar Apr 29 '22 21:04 DamienBitrise

Facing this problem as well.

Nikoloutsos avatar Jul 22 '22 09:07 Nikoloutsos

Hi, thank you for contacting Bitrise. This is the expected behavior and here's the response from our engineer.

Envman is a file-based env store tool. When you add an env var it writes to a file. When you execute a command with envman (like Bitrise steps) envman reads this file and passes it to the standard go execution package. So technically it does not know anything about how to set these or what an env var is.

You can check the Usage example: Simple Bash example in the Readme.md file for further explanation.

tzuhan-bitrise avatar Aug 25 '22 04:08 tzuhan-bitrise

Is there a command that can be run to load the new Env Vars into the current shell maybe?

DamienBitrise avatar Jan 04 '23 19:01 DamienBitrise

Hi @DamienBitrise , adding the env to the current shell session and adding it to the envstore file when envman add is executed is a valid feature request, even if the current behavior is by design.

Is there a command that can be run to load the new Env Vars into the current shell maybe?

Unfortunetly there isn't a single command you could use.

envman print prints the content of the envstore file in the format:

KEY_1: VALUE_1
KEY_2: VALUE_2
...

, or in a json format --format json.

godrei avatar Jan 16 '23 15:01 godrei

i've overcome this problem long time ago by using:

export FOO="BAR"

Nikoloutsos avatar Jan 16 '23 15:01 Nikoloutsos