Run a job on specific tag, after other jobs are completed

Hello, I’m trying to run a job only for specific tags ( and that’s working ) but only after other jobs are completed.

workflows:

  analyze_test_publish:
    jobs:
      - analyze
      - test
      - testTag:
          requires:
            - analyze
            - test
          filters:
            # ignore any commit on any branch by default
            branches:
              ignore: /.*/
            # only act on version tags
            tags:
              only: /^[0-9](\.[0-9]+)+(\-\w+\-[0-9]+){0,1}$/

With this configuration I got
image
While if I remove the requires block it run as expected, but the testTag runs together with other jobs.

Thank you

Hi @4face-studi0,

Tags are not built by default, so the analyze and test jobs are not run, meaning the testTag job’s dependencies are never met. You have to add a filter to explicitly allow tags to build. Something like this should work:

workflows:
  analyze_test_publish:
    jobs:
      - analyze:
          filters:
            # also act on version tags
            tags:
              only: /^[0-9](\.[0-9]+)+(\-\w+\-[0-9]+){0,1}$/
      - test:
          filters:
            # also act on version tags
            tags:
              only: /^[0-9](\.[0-9]+)+(\-\w+\-[0-9]+){0,1}$/
      - testTag:
          requires:
            - analyze
            - test
          filters:
            # ignore any commit on any branch by default
            branches:
              ignore: /.*/
            # only act on version tags
            tags:
              only: /^[0-9](\.[0-9]+)+(\-\w+\-[0-9]+){0,1}$/

That’s a fair bit of duplication, but you can use YAML anchors to reduce that a bit:

workflows:
  analyze_test_publish:
    jobs:
      - analyze:
          filters: &tag-version-filter
            # also act on version tags
            tags:
              only: /^[0-9](\.[0-9]+)+(\-\w+\-[0-9]+){0,1}$/
      - test:
          filters:
            <<: *tag-version-filter
      - testTag:
          requires:
            - analyze
            - test
          filters:
            <<: *tag-version-filter
            # ignore any commit on any branch by default
            branches:
              ignore: /.*/

Hope this helps!

Stig

1 Like

@stig Wow! This is awesome! Thank you for a clear explaination + the better way to handle that!!

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