I want to execute a job only when a tag is set. I have set the trigger and have given the variables as well, along with the condition as shown below:
trigger:
tags:
include:
- '*'
branches:
include:
- '*'
pr:
branches:
include:
- main
pool:
vmImage: ubuntu-latest
variables:
- name: isCommitToMain
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
- name: isPullRequest
value: $[eq(variables['Build.Reason'],'PullRequest')]
- name: isTag
value: $[eq(variables['Build.SourceBranch'],'refs/tags/*')]
stages:
- stage: Analysis
jobs:
- job: without_any_condition
steps:
- script: |
echo "without any condition"
- job: with_commit_to_main_condition
condition: eq(variables.isCommitToMain,true)
steps:
- script: |
echo "with commit to master condition"
- job: with_pr_condition
condition: eq(variables.isPullRequest,true)
steps:
- script: |
echo "this is with PR condition"
- job: with_tag_condition
condition: eq(variables.isTag,true)
steps:
- script: |
echo "this is with tag condition"
When I create a Tag, I expect the job without_any_condition and job with_tag_condition to execute.
But on creating the tag, I see that the with_tag_condition job is skipped.
Suggestions please? What am I doing wrong here?
