Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change environment variable value between tasks in Build vNext

Is there a way to persist changes in environment value between tasks in Visual Studio Team Services? I'm using Powershell to change it but it only changes it in the task not the whole process.

script 1

Write-Verbose "Before: $Env:SuperVersion"
$Env:SuperVersion = $NewVersion
Write-Verbose "After: $Env:SuperVersion"

script 2

Write-Verbose "Final: $Env:SuperVersion"

I see the change at After but Final is always getting the original value

like image 289
cilerler Avatar asked Oct 08 '15 22:10

cilerler


People also ask

How do you pass variables between tasks in Azure DevOps?

Logging command called task. setvariable lets us pass variables across Tasks. Task. setvariable sets the value to a variable which by default can be used in any Task within a Job or across the Jobs of a given Stage.

Can you use env variables in Yaml?

PY-yaml library doesn't resolve environment variables by default. You need to define an implicit resolver that will find the regex that defines an environment variable and execute a function to resolve it. You can do it through yaml.

How do I set an environment variable in Azure?

To set environment variables when you start a container in the Azure portal, specify them in the Advanced page when you create the container. Under Environment variables, enter NumWords with a value of 5 for the first variable, and enter MinLength with a value of 8 for the second variable.


1 Answers

Based on this issue following line will do the trick.

Write-Host ("##vso[task.setvariable variable=SuperVersion;]$NewVersion")

You may find more commands like that in here

like image 162
cilerler Avatar answered Sep 19 '22 11:09

cilerler