How do you trigger a CD pipeline dependent on a CI pipeline succeeding?

Viewed 470

I want:

  • PipelineA builds and uploads an artifact, when that completes successfully
  • PipelineB runs and downloads PipelineA's artifact

PipelineA's trigger:

trigger:   
    branches:
        include:
        - release/*
        - master  

This works as expected, PipelineA will run and build an artifact whenever a code change is made.

PipelineB's trigger (does not work!)

trigger: none # important! we do not want to be deploying to environments without an artifact

resources: 
    pipelines:
    - pipeline: PipelineALocal # does not matter, only for pulling down local vars
      source: PipelineA # the exact name defined in ADO
      trigger: true # tried every variant under the sun to get this working but this pipeline will never run

I've tried every combination of triggers including the (apparently should always work trigger: true?) but nothing works. The pipeline never triggers.

Under resources.pipelines.branches.include, I've tried: refs/heads/master, master, refs/heads/release/*, release/* and everything in-between. With proper YAML formatting of course.

The documentation is very confusing, but I managed to figure out how to get the runID from a pipeline alias.

--

I've resorted to trying to go through the triggers UI and configure a PipelineB Build completion trigger based on PipelineA succeeding.

That only works for the master branch, so I cannot use variables['Build.SourceBranch'] to determine if this is a staging or release build.

How do you trigger a CD pipeline dependent on a CI pipeline succeeding?

1 Answers

There are any circumstances of separation of these pipelines?

I use only one yml for CI and CD using stages and depend CD from success of CI stage:


stages:
- stage: CI
  jobs:
  - job:
    ...

- stage: CD
  dependsOn: CI
  jobs:
  - job:
    ...

Edit2:

I tried this

trigger: none

resources: 
    pipelines:
    - pipeline: cd-test
      source: ci-pipeline
      trigger: true

on my project and this is working fine but you must remembet that trigger in PipelineB (in my case ci-pipeline) must be on master branch when I deleted them from master it was stop working.


Edit1:

To enable triggering from another pipeline you must go to Edit Pipeline definition -> Triggers enter image description here

and set trigger: enter image description here

Related