I need to be able to do this too. It seems as if every command step is given a completely separate instance of bash to run in or something. It’s also quite hard to test by pushing small iterations, trying to make it work on CI when it already works locally…
I just tested and this indeed looks to be true; if I run command1 && command2, command 2 can use env set from command1 but command3 on a new line in the yml cannot. So it does seem as though each separate command is run using an isolated shell or something…I might have to resort to storing my envs vars in temp files instead, so that subsequent commands can access them…
More editing, more follow ups. I found this https://www.compose.io/articles/experience-with-circleci/
Which mentions that David Lowe of Circle says:
“You’ve got the right idea, but unfortunately, ‘export AWSSECRETKEY’ won’t quite work because each command runs in a separate shell”
And then he goes on to recommend storing them in a files, as I suggested, but instead there is actually an env file for Circle, you can add to it from one script by doing:
“echo ‘export AWS_SECRET_KEY=1234’ >> ~/.circlerc”
It’s just annoying to emulate/test this locally…but at least it will (probably) work!