I have two Azure pipelines, A and B. I'm aiming to have pipeline B execute whenever pipeline A completes successfully, but I also want pipeline B to be triggered independently based on its own criteria. My second pipeline, B, is defined as follows:
trigger:
- master
resources:
pipelines:
- pipeline: mySourcePipeline
source: Source Pipeline
trigger: true
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
submodules: true
lfs: true
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- task: Bash@3
inputs:
targetType: 'inline'
script: echo 'Second pipeline is triggered'
I'm following the guidance provided here: Azure Pipelines Triggers.
However, in my scenario, pipeline A completes successfully, yet the second pipeline (B) doesn't get triggered. What might be causing this issue?
Any insights or suggestions would be greatly appreciated!
What I'm aiming for is:
Assuming that first pipeline looks like
trigger:
branches:
include:
- staging
- production
variables:
- name: isProduction
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/production')]
- name: isStaging
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/staging')]
stages:
- stage: A
jobs:
- job: A1
steps:
- script: |
echo "isProduction: $(isProduction)"
echo "isStaging: $(isStaging)"
echo "Build.SourceBranch $(Build.SourceBranch)"
And it is named firstpipeline
(not the yaml file, but the name of the pipeline in Azure Devops portal).
Then your secondary pipeline should look like
trigger:
- staging
- production
resources:
pipelines:
- pipeline: firstpipeline # Name of the pipeline resource
source: firstpipeline # Name of the triggering pipeline
trigger:
branches:
include:
- staging
- production
variables:
- name: isProduction
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/production')]
- name: isStaging
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/staging')]
stages:
- stage: A
jobs:
- job: A1
steps:
- script: |
echo "isProduction: $(isProduction)"
echo "isStaging: $(isStaging)"
echo "Build.SourceBranch $(Build.SourceBranch)"
So as a source you should use name of the pipeline not the yaml file.
You can find this here on github