Setting environment variables with a command fails

If you wanted to do something like that, you could do it like this:

deployment:
  production:
    branch: tlester/jenkins
    commands:
      - |
        VERSION: $(tail -1 version)
        eval $(aws ecr get-login)

I didn’t run that myself but something like that should work. For deployments, anything within commands will run with Bash.

The pipe (|) allows us to run a multiline command in YAML. If you were to do it as two separate commands, it wouldn’t work because each command would get it’s own shell meaning VERSION wouldn’t exists in the second command.

1 Like