Using environment variables in command steps

1 minute read

In order to interpolate environment variables into codeship-steps.yml command steps, the entire step must be wrapped in a shell command.

For example, the command without a shell wrapper…

- service: app
  command: echo The branch name is: $CI_BRANCH

…results in:

The branch name is: $CI_BRANCH

Whereas a command with a shell wrapper…

- service: app
  command: /bin/sh -c 'echo The branch name is: $CI_BRANCH'

…results in:

The branch name is: master