Home > Net >  Specify build branch based on branch used in triggering pipeline Azure Devops
Specify build branch based on branch used in triggering pipeline Azure Devops

Time:12-21

Say I have two pipelines: PL1 and PL2 and that PL2 is triggered by PL1. Say I ran PL1 on the master branch, I want PL2 to also get triggered for the master branch. When PL1 is triggered on another branch, like releases/X.X.X I want PL2 to also be triggered on the releases/X.X.X branch. Can I do that? Right now PL2 is always using master when it gets triggered

CodePudding user response:

I tried to replicate the scenario.

First pipeline:

trigger:
  - none

stages:
  - stage: first
    jobs: 
     - job: firstJob
       continueOnError: false
       steps:
         - bash: echo "first from test branch"

Second Pipeline:

resources:
  pipelines:
  - pipeline: firstPipeline
    source: first-pipeline
    trigger:
     branches:
      include:
        - ${Build.SourceBranch}

stages:
  - stage: second
    jobs: 
     - job: secondJob
       steps: 
         - bash: echo Test-branch

I tested these from two different branches and each time the source code of second pipeline was picked up based on the first pipeline's branch.

PS: Both of my pipeline YAML are in same repository

  • Related