huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
44 stars 22 forks source link

How to access build parameters in other build jobs #134

Closed henrikstromberg closed 4 years ago

henrikstromberg commented 4 years ago

I have a Trigger buildtask in one project with the build paramerter buildParameters: "ServiceName: sample-service"

How do I access in in my other build pipeline as a parameter to a powershell script or directly in the poweshell script?

this is not documented https://github.com/huserben/TfsExtensions/blob/master/BuildTasks/overview.md#build-parameters

I also tried to use this in the other buildpipline but no value vas set Write-Output "Fetching variable TriggeredBuildIds:" Write-Output "$($env:TriggeredBuildIds)"

huserben commented 4 years ago

Hi @henrikstromberg

When you pass a variable you will need to define this variable in the build that is triggered and specify it to be settable at queue time. So that means if you have two builds:

Your Build A is triggering Build B with the mentioned configuration of ServiceName: sample-service. In Build B you then must have defined a variable called ServiceName that has the Settable at Queue Time box ticked. In Build B you then can access this like any other variable:

The TriggeredBuildIds variable is set when you specify the check box in the settings under Stored Environment Variable. It is then available in the build that is triggering (Build A in our example).

Did this clarify a bit the usage of the variables?

henrikstromberg commented 4 years ago

Thanks for the help it solved my problem :-)