I have added a job in the existing circleci workflow, I would like to run that job only if a yaml file is changed in the repo. Is there any way to do it ? TIA.
Asked
Active
Viewed 1,110 times
3 Answers
2
you can detect changes in circlci build step and run job only if yml files changed
- run: |
git show --name-only ${CIRCLE_SHA1} | grep .yml
if [ $? -eq 0 ]; then
echo "yml files changed"
// Do your job steps
fi

Mesar ali
- 1,832
- 2
- 16
- 18
1
No. There's no way to do that. You can follow @crack_iT's answer as that's the closest but technically the job still runs. The only option is to end the job early.

FelicianoTech
- 3,894
- 2
- 13
- 18
-
Hi @FelicianoTech could you please answer one more query https://stackoverflow.com/questions/69253933/how-to-execute-a-docker-run-command-in-circleci-job TIA – flux0987 Sep 20 '21 at 12:20
0
Yes this is now possible. 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. You can set a pipeline parameter when changes are detected under a folder and add a when condition attribute with that pipeline parameter in the job.

kuzdogan
- 554
- 7
- 13