How to run a job (or a step) only when a specified file changed?

Is there some way to run a job (or even a step) depending on the exit code of git diff --quiet HEAD~ foo/?

I’m look for something like filters (but filters seems only check branch or tag) or condition (but condition only evaluates parameters, and not seems possible set a parameter as result of a bash script)

Hi Alan.

Conditional jobs aren’t possible currently, though that would be a good feature request.

You can create a conditional step using bash:

  - run:
      name: Check branch
      command: |
        if [ "${CIRCLE_BRANCH}" == "master" ]; then
           echo "foo"
        fi

is one example. a web search for bash conditionals will help.If you run into issues and show the failed check I know there are folks here on the forums who may be able to help as well.

2 Likes

Thank you very much @drazisil!
I’ll add a feature request to be able to do it as a conditional filter
But your suggestion should do the job for now

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.