Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing release variables between two agent phases

I'm working with TFS on-premise. My issue is that during a release I have two agent phases separated by a manual intervention.

In the first agent phase, I set a variable with:

Write-Verbose $("##vso[task.setvariable variable={0};]{1}" -f $variablename, $variable)

Problem is that in the second agent phase, this variable doesn't exist anymore, even if the same agent is used for the second release phase.

How may I pass a variable between two agent phases during the same release?

like image 303
Pierre P. Avatar asked Dec 19 '17 16:12

Pierre P.


People also ask

How do you pass variables in a pipeline release?

To passing variables in release pipeline, we can set variables by logging command. Please see Set variables in scripts for details.

How do you pass variable from one phase to another Azure DevOps pipeline?

Passing variables between tasks in the same job In a script task, you need to print a special value to STDOUT that will be captured by Azure Pipelines to set the variable. For example, to pass the variable FOO between scripts: Set the value with the command echo "##vso[task. setvariable variable=FOO]some value"

How are variable groups used in release pipeline?

To use a variable group, open your pipeline. Select Variables > Variable groups, and then choose Link variable group. In a build pipeline, you see a list of available groups. In a release pipeline, for example, you also see a drop-down list of stages in the pipeline.


1 Answers

There is no way to persist variables (no matter powershell variables or VSTS user defined variables) between two agent phases (and environments) for now.

And there is a related issue Variables set via logging commands are not persistent between agents, you can follow up.

The work around for now is define the variable again in next agent phase.

like image 104
Marina Liu Avatar answered Oct 22 '22 02:10

Marina Liu