I have two pipelines - one for CI and the other for CD. Want to trigger the CD pipeline after CI pipeline has completely finished. After setting up the triggers (through YAML), both of my pipelines get triggered together so CD finishes even before CI has completed.
How can I trigger the CD pipeline, only after the CI has finished off?
My CI pipeline is as follows:
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"'
My CD pipeline is as follows:
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'