Azure-pipelines-tasks: Persisting environment variables across agent phases

Created on 19 Jan 2017  Â·  23Comments  Â·  Source: microsoft/azure-pipelines-tasks

Similar enough to #2111 that one could argue that issue be re-opened instead. But, since that issue was closed before the introduction of server phases I hope this will be revisited.

Most helpful comment

Is the the example at https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-phases.md#output-variables only Yaml build definitions?

Was looking into using this pattern in RM for getting output variables from an ARM deployment downstream to other phases but I can can't seem to figure out the magic incantation to solve this.

Specifically in a similar PowerShell scenario listed above.

$variableName = 'abc'
$value = 'def'
Write-Host "##vso[task.setvariable variable=$variableName;isoutput=true;]$value"

All 23 comments

Closing the issue here. Not an issue with the tasks in this repo.

This work has already started in the agent repo and server side.

@ericsciple Glad to hear it is on the radar. Can you provide a hyperlink to the relevant issue, PR, branch, blog, or backlog?

The backlog is internal. There's commits in the agent repo with "output variables" in the commit message.

A dependency for completing the work is moving the agent to .Net Core 1.1. We're locking down for the TFS 2017 U1 release right now, so that work is on hold for a couple weeks.

really need this! :(

@ericsciple - Anyone actively looking into it? Really want this as it can significantly improve our release process. Whenever we use a Server Phase like Manual intervention task, we have to re-initialize the variables in the next Agent phase.

@TingluoHuang any rough ETA on output vars?

@whihathac afaik the functionality is very close to being completed. requires server side work as well and I believe that work is already in master.

Hey @ericsciple, this work is marked as complete - do we have any eta on the server side work or is it also done?

@TingluoHuang ?

Also curious how I can persist a variable and re-use in another phase, eg after manual intervention step.

When we're done here with output variables, they will just flow

The change has been made. Is it present in Agent version 2.120.2?
I tried to set the variable with PS Inline script:

$variableName = 'abc'
$value = 'def'
Write-Host "##vso[task.setvariable variable=$variableName;isoutput=true;]$value"

It did not persist the value 'def' into the second agent phase.
In fact, when using isoutput, the variable value is not persisted even in the same agent phase.

Any updates on this? This would really simplify our release pipeline

Is the the example at https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-phases.md#output-variables only Yaml build definitions?

Was looking into using this pattern in RM for getting output variables from an ARM deployment downstream to other phases but I can can't seem to figure out the magic incantation to solve this.

Specifically in a similar PowerShell scenario listed above.

$variableName = 'abc'
$value = 'def'
Write-Host "##vso[task.setvariable variable=$variableName;isoutput=true;]$value"

So this is not possible in "vNext" builds, only yaml?

@ericsciple @motowilliams

404

And after a year... nothing

But:

You cannot pass a variable from one job to another job of a build pipeline unless you use YAML.

And there will not be such an option in the future. As each agent is a container, enabling cross agents data persistence, means having a shared storage or mounts inside the container. The only way to do it is save the values into like a storage account / s3 and then read it as the first step of the next job.

OR you create your own containerized images with agent self registration and you run it on your k8s cluster so you have all the control you want.

The closest you can do is try to use rest api to change values of variable groups but then you loose the ability to run in parallel as the variable groups are evaluated once the agent starts.

Thank You ,
Eventually i found a workaround by Jury rigging an Old SQL Service , to act
as sort of value holder.

On Thu, Aug 29, 2019 at 2:00 PM Arie Heinrich notifications@github.com
wrote:

The closest you can do is try to use rest api to change values of variable
groups but then you loose the ability to run in parallel as the variable
groups are evaluated once the agent starts.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/azure-pipelines-tasks/issues/3455?email_source=notifications&email_token=AFPKY6GAG6UIE62G72S6G2LQG6T5HA5CNFSM4C46VEN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ODGBQ#issuecomment-526136070,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFPKY6E5E5DX2JGKPJLZTLDQG6T5HANCNFSM4C46VENQ
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gregpakes picture gregpakes  Â·  3Comments

NatMarchand picture NatMarchand  Â·  3Comments

MichaelWhiteCodingForFun picture MichaelWhiteCodingForFun  Â·  3Comments

ThomasBarnekow picture ThomasBarnekow  Â·  3Comments

yaananth picture yaananth  Â·  3Comments