Skip a Job in a specific situation

:wave: I’ve got a CCI job that looks something like this:

  - docker-build-job:
      # ... only build container if on `main` or relevant files changed
      # ... tag with branch-name
  - job-a:
      executor:
        # ... uses `main` executor
      requires:
        - docker-build-job
  - job-b:
      executor:
        # ... uses `main` executor
      requires:
        - docker-build-job

This current state is a result of a few things we tried:

  1. We tried to use a branch filter on docker-build-job, but that meant that downstream jobs (job-a, job-b) never run when docker-build-job runs.
  2. To solve that, we add a step to docker-build-job that checks branch and file changes to make sure we only build when needed.

Unfortunately, in order to determine if we should/should not skip, we have to spin up the docker environment, which takes ~1 min at least.

What we’d like is:

  • in main, always build the docker image and use it to run job-a, job-b
  • in branches, if certain files change, build the docker image for the branch and use it to run job-a, job-b (*)
  • in branches, when no relevant files changed, only run job-a, job-b using the main container (the most common)

Here are the priorities as of now:

  • MOST IMPORTANT: 0 time spent spinning up the docker-env in the most common case - the last bullet above.
  • SECONDARY: use an executor with the current branch only if the relevant files changed on this branch.

Any ideas how I could achieve this?

You can use file-path orb of circleci to solve your problem.
Here is the link which may help you.

@bigH-chime we’re working through a solution that we think would make this scenario easier to set up. Any chance you’re willing to give feedback on whether our approach meets your use case? If yes, can you email triggers-feedback@circleci.com?