问题描述
在Azure DevOps YML管道中,是否可以从管道B阶段触发管道A阶段1?
推荐答案
您可以使用Trigger Build自定义任务。它会触发整个管道,但您可以使用阶段条件跳过不应该运行的阶段。
# 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)
...