Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one build pipeline send a value as a parameter to the next pipeline it triggers in Azure DevOps

I have a build pipeline, lets say A - that stores a file (this file has a variable value that is set within that build pipeline) within a folder. This Pipeline A triggers another Pipeline B that Publishes the folder as an artifact using the Publish artifact task. But the folder name is dynamic as it is fetched from that file within Pipeline A. I need to pass on the file with that variable value from Pipeline A to Pipeline B while triggering it. Is there any way to do this in Azure DevOps, without using the yaml pipelines?

I have a little complex set of pipelines that I set up using the Classic mode, and converting them all to yaml would take a long time, so would like to know if there is any work around to this.

like image 372
AK123 Avatar asked Jan 28 '26 10:01

AK123


2 Answers

There are few workarounds:

  1. Create a variable group, and during the Pipeline A set the variable value there with Rest API, then Pipeline B use this variable.

  2. During Pipeline A update the Pipeline B definition with the new value with Rest API.

  3. In Pipeline A trigger the Pipeline B with Trigger Build Task, there you can pass the variable value to the Pipeline B (you do it in the "Build Parameters" field).

like image 50
Shayki Abramczyk Avatar answered Jan 31 '26 16:01

Shayki Abramczyk


I don't think there's a clean way to do this if you need to trigger the build by adding Pipeline A under the triggers section of Pipeline B.

Consider triggering Pipeline B when Pipeline A completes using the REST API. That way, you can have your 'file path' as a variable on Pipeline B and pass it in the parameters collection.

Something like:

POST https://dev.azure.com/{organization}/{project}/_apis/build/builds?ignoreWarnings={ignoreWarnings}&checkInTicket={checkInTicket}&sourceBuildId={sourceBuildId}&api-version=5.0

{
    "definition": {
        "id": 1234
    },
    "parameters": "{\"fileName\":\"yourfilename\"}"
}
  • filePath would be the name of your variable in Pipeline B

Have a look at the Builds - Queue documentation for more info.

like image 41
Charlie Drewitt Avatar answered Jan 31 '26 14:01

Charlie Drewitt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!