Conditionally stop job when only change was to config.yml file

You may encounter a situation where you are overhauling your config.yml file and don't want to run a build on each change.

While you work on the changes you can add the following to the start (after the - checkout step) in each of the workflow jobs:

- run: |
    changes=`git show --name-only ${CIRCLE_SHA1} | tail -n +7`

    if [ "$changes" = ".circleci/config.yml" ]; then 
      echo "Only found a configuration change. Stopping build" 
      circleci-agent step halt
    fi

This will check to see which files changed in the commit, and if it's only the configuration file, it will exit the job successfully with the "circleci-agent step halt" command

Once you are happy with the changes in your configuration file you can remove the above run step and it will start to process your builds as normal.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.