As of Circle CI 2.1, we can define custom commands and new CircleCI CLI.
I found the following code is useful to exit CircleCI jobs when some specific file/directory was changed in the latest commit:
# .circleci/config.yml commands: check-changed-files-or-halt: parameters: pattern: type: string steps: - run: git show -m HEAD --name-only --pretty="" | egrep -q '<< parameters.pattern >>' || circleci step halt jobs: test: executor: node steps: - attach-workspace - check-changed-files-or-halt: pattern: ^(src|test)|(.js|ts)$ - run: yarn install - run: yarn test
However, the command
git show -m HEAD --name-only --pretty="" only shows the latest commit's change, so use with merging Pull Request with tasks such as deployment.