Job is being executed despite conditions not met

version: 2.1
# Use a package of configuration called an orb.
orbs:
  # Declare a dependency on the welcome-orb
  welcome: circleci/welcome-orb@0.4.1
# Orchestrate or schedule a set of jobs

jobs:
  custom:
    docker:
     - image: alpine
    when: 
    steps:
      - run: 
          name: print tag
          command: echo << pipeline.git.tag >>
    

workflows:
  # Name the workflow "welcome"
  welcome:
    # Run the welcome/run job in its own container
    jobs:
      - custom:
          filters:
            tags:
              only: deploy
      - welcome/run

Why does the “custom” job run even if pipeline.git.tag is empty?

Thank you

:wave: Hello @bananas. Welcome to the CircleCI Discuss community!

By default, CircleCI won’t build for any tag unless explicitly specified (which you have). However, the default behaviour is to build for all branches.

So in your case, you also need to explicitly exclude all branches so the workflow only runs when the deploy tag is pushed:

workflows:
  # Name the workflow "welcome"
  welcome:
    # Run the welcome/run job in its own container
    jobs:
      - custom:
          filters:
            tags:
              only: deploy
            branches:
              ignore: /.*/
      - welcome/run

 
You can find more information about filtering in our documentation:

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