I'm using circleCI version 2 and my config.yml
like this:
version: 2
jobs:
a:
steps:...
b:
steps:...
workflows:
version: 2
main_pipeline:
jobs:
- a
- b
I want only to build when a change happens in the directory.
job a
for folder a
job b
for folder b
when folder a
changes, build only job a
.
function trigger_job() {
job_name=$1
curl --user ${CIRCLE_API_TOKEN}: \
--data build_parameters[CIRCLE_JOB]=$job_name \
--data revision=$CIRCLE_SHA1 \
https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/$CIRCLE_BRANCH
I use this function for trigger job and find different by git-diff like this git diff-tree --name-only $(git log -n 2 --pretty=format:"%H") | grep project
CircleCI now has support for dynamic configs (instead of a single static config file), and with that a path-filtering
orb is available that can detect changes under a folder and set pipeline parameters accordingly.
See https://circleci.com/docs/2.0/using-dynamic-configuration/#execute-specific-workflows-or-steps-based-on-which-files-are-modified
You can also check out our config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With