I want to make one of the jobs in my pipeline optional based on an environment variable. The reason is the job takes a long time (e.g. an hour) but it doesn’t need to be done every time - for example, not when re-deploying the same piece of work.
I created an environment variable for the project called DISABLE_ENV_SETUP and set it to 1.
Then I put this in the config.yml:
jobs:
build_env_setup:
<<: *defaults
steps:
- run:
name: Skip env set up if disabled
command: if [ -z "${DISABLE_ENV_SETUP}" ]; then echo "Skipping env set up because of CircleCI environment variable DISABLE_ENV_SETUP."; circleci step halt; fi
Unfortunately this doesn’t work.
I’m not sure if I’m using the environment variable incorrectly or am misunderstanding something. Can anyone help?