How to pass variables with pipeline trigger in Azure Pipeline

Tsuyoshi Ushio
2 min readJan 10, 2020

--

Pipeline triggers are introduced. It enables one pipeline is completed then subsequent pipeline works. Then, how to pass the variables between two?

Pipeline Trigger

Pipeline Triggers

If you want to execute subsequent pipeline automatically, all you need is to add this section on your pipeline yaml. It shows that when the Parent.CI completed, this pipeline start working. The point is trigger: none Azure Pipeline seems trigger: master by default. So if you didn’t add trigger: none and you commit something to master branch, it automatically start this pipeline. Also, pipeline triggers also triggers this pipeline after the Parent.CI complete.

resources:
pipelines:
- pipeline: parent
source: Parent.CI
trigger:
branches:
- master
trigger: none

Passing Variables

Then how to pass the variables from Parent to Child? We have no way to directly pass the variables. However, we can pass it through artifact.

Parent.CI

Look at this example. It is simply save environment as file. We can choose the format, however, I save it as logging command.

Child.CI

The child pipeline echo the file. Then the variables are restored. You need to fill ` <YOUR_PROJECT_ID_HERE>` section. However, if you use editor on the Azure Pipeline, you can choose a Project and a Pipeline as a drop down list.

Output

Variables output

--

--

Tsuyoshi Ushio
Tsuyoshi Ushio

Written by Tsuyoshi Ushio

Senior Software Engineer — Microsoft

Responses (1)