How to trigger one pipeline stage from another pipeline in Azure DevOps?

1.1k Views Asked by At

In azure DevOps YML pipelines, is it possible to trigger a pipeline A stage1 from pipeline B stageY ?

1

There are 1 best solutions below

0
qbik On

There's a Trigger Build custom task that you can use. It triggers the whole pipeline, but you can use stage conditions to skip stages that should not run.

# in pipeline A
- task: TriggerBuild@3
  displayName: 'Trigger a new build pipelineB'
  inputs:
    buildDefinition: 'pipelineB'
    waitForQueuedBuildsToFinish: true
    waitForQueuedBuildsToFinishRefreshTime: 10
    buildParameters: 'stageY: true, stageX: false, stageZ: false'
    authenticationMethod: 'OAuth Token'
    password: '$(System.AccessToken)'
# in pipeline B
variables: []  # do not define stageX, stageY, stageZ variables here, or it won't work
stages:
- stage: stageX
  condition: ne(variables.stageX, false)
  ...
- stage: stageY
  condition: ne(variables.stageY, false)
  ...
- stage: stageZ
  condition: ne(variables.stageZ, false)
  ...