Workflow run environment does not equal use of environment object

circle.yml

#1

When running with command-specific environment, passing ENV variables directly into the command is not the same as defining environment object to run.

Documentation hints that the following 2 scenarios should be equally treated, but they are not:

  - run:
      name: Migrate database
      command: DB_PASSWORD=$STAGING_DB_PASSWORD DB_USER=app_staging DB_NAME=app_staging DB_SOCKET=/cloudsql/app-staging:europe-west1:app-stag bundle exec rake db:migrate

vs

  - run:
      name: Migrate database
      command: bundle exec rake db:migrate
      environment:
        DB_PASSWORD: $STAGING_DB_PASSWORD
        DB_USER: app_staging
        DB_NAME: app_staging
        DB_SOCKET: /cloudsql/app-staging:europe-west1:app-stag

#2

The main issue I see with your example is that you are trying to interpolate ENVARS which is not currently supported.


#3

It’s working in the first given one-liner example though. Maybe worth to revise the documentation in that regard.


#4

It makes sense that it works in the one-liner because you are not really “exporting” an ENVAR but running it in line as a part of the command. If you run any other command in the step the ENVAR will be gone since we run each step in a new shell.

I agree that we should make this clear because it is a common source of confusion and frustration.

Documentation hints that the following 2 scenarios should be equally treated

Can you point me to this part of the docs?


#5