2
votes

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.

2
How do you trigger pipeline B from A?Shayki Abramczyk
By adding Pipeline A under the Triggers (Build Completion) section of Pipeline B.AK123
The solution/workaround of Shayki is the better way. What's the result after you trying it?starian chen-MSFT
What I did was, create a variable in Pipeline B. I tried to send the value of the variable from Pipeline A, by using the REST API call to queue Pipeline B with this variable as a parameter.AK123

2 Answers

1
votes

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.

3
votes

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).