2

How is it possible to reference a variable within a variable in the new scripting system of VSTS?

e.g:

RemoteMachineFqdn: somemachinename.somedomain

RemoteMachineUncPath: \\$(RemoteMachineFqdn)\c$\

In the aforementioned example, assume there are tasks that both use CMD and Powershell scripts with the given variables. I tried using the the variables by referencing their values from the environment but it does not work for both scenarios since %variable% works only in CMD and $env:variable - only in Powershell.

What is the standard way to do it?

Ivan Prodanov
  • 34,634
  • 78
  • 176
  • 248

1 Answers1

0

What you are looking for is Logging Commands. To invoke a logging command, simply emit the command via standard output. For example, from a PowerShell task:

##vso[task.setvariable variable=testvar;]testvalue

This example sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39