Using "requires" on a job not working as expected?

I have a workflow with multiple jobs. At one point, 2 jobs run that will build a develop and a production build, then a job runs that notifies that the production build is built.

build production job filters on branch name
notify production built requires “build production”

I’m currently running the workflow on a branch that does not build production, however the notification is still running, which makes me think the require isn’t really doing anything as the “build production” job never ran.

I would expect the notification job to not run, since one of the “require” parameters isn’t met.

Hi,

We need to see what the “workflows” portion of your config looks like to help figure out this issue.

Sorry to hijack the thread but I have the same problem. Here’s a sample config:

version: 2.1

jobs:
  first-job:
    docker:
      - image: ubuntu
    steps:
      - run: echo "this is the first job"
  second-job:
    docker:
      - image: ubuntu
    steps:
      - run: echo "this is the second job"
  third-job:
    docker:
      - image: ubuntu
    steps:
      - run: echo "this is the third job"

workflows:
  first-workflow:
    jobs:
      - first-job
      - second-job:
          filters:
            branches:
              only:
                - /.*special/
      - third-job:
          requires:
            - first-job
            - second-job

And here are two test runs of the same commit, but with two different branch names.

Notice that third-job always runs, even in the case where second-job was not run due to the branch name filter. I would expect third-job to only ever run if both first-job and second-job have completed successfully.

Hi @tamlyn,

This is intended behavior. Branch filtering is not applied downstream. You will need to add branch filtering to third-job if you’d like for it to require second-job.

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