我有两条管道——一条用于 CI,另一条用于 CD。想要在 CI 流水线完全完成后触发 CD 流水线。设置触发器(通过 YAML)后,我的两个管道一起触发,因此 CD 甚至在 CI 完成之前就完成了。
只有在 CI 完成后,我才能触发 CD 管道?
我的 CI 管道如下:
pr:
- develop
trigger:
- develop
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/dockerfile'
tags: |
$(tag)
- stage: Push
displayName: Push to Reg
condition: and(succeeded(), in(variables['Build.SourceBranch'], 'refs/heads/develop'))
jobs:
- job: push
steps:
- task: Bash@3
inputs:x
targetType: 'inline'
scriptx: 'echo "this is the push to reg task"'
我的 CD 管道如下:
resources:
pipelines:
- pipeline: cd
source: pipeline-trigger-ci
trigger:
branches:
include:
- refs/heads/develop
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'