Conditionally Stop Job When Only Change Was to config.yml File

Prevent Build With Only Config Changes

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


circleci-agent step halt Command

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

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.


[ci skip] Within Commit Message

Another option is to add "[ci skip]" within your commit message to prevent a build when commiting changes to your config.yml file.


Additional Resources

Was this article helpful?
4 out of 7 found this helpful



Article is closed for comments.