1

In TFS 2017, when a release definition is created a set of custom variables can be created too.

In the scope of an Agent, Is possible to change the value of one variable?

I tried with an inline powershell script:

$env:MyVariable = "changed value"

also try with :

[Environment]::SetEnvironmentVariable("MyVariable ", "changed value.", "User")

without success.

XtianGIS
  • 967
  • 16
  • 39

2 Answers2

2

You could use the Logging command to change the custom variable's value.

In your PowerShell script file(script1.ps1), write:

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

Then add a Powershell script to run this file.

And you could add another Powershell script file(script2.ps1) to output the custom value. Run this file after script1 to check if the value has been changed successfully.

Here is a similar question: How to change a tfs build variable in script

Community
  • 1
  • 1
Tingting0929
  • 4,142
  • 1
  • 14
  • 14
-1

Did you try Write-Host?

Write-host $env:OutputVar

Can't check myself now, but you can take a look here for detail.

Oxoron
  • 664
  • 1
  • 7
  • 26