在 VSTS 中,如何以另一个变量的名称引用一个变量?

In VSTS, how can I reference a variable in the name of another variable?

我有一个包含环境部署凭据的变量组,test_hosttest_token 等。我希望能够在发布任务中使用这些变量的值,但我不知道' 想要输入环境名称 (test),因为这可能会在环境之间发生变化。

如何使用当前环境名称引用 test_host 变量?我试过 $($(Release.EnvironmentName)_host) 导致字符串 $(test_host) 被传递到我的脚本。我如何让它解决 $(test_host)?

注意 - 我正在尝试将这些值传递到 powerhsell 脚本中,因此在参数字段中我有 -deployHost $($(Release.EnvironmentName)_host),这导致 -deployHost $(test_host) 被执行。

更新 1 虽然这些值最终会传递到 powershell 脚本中,但该脚本位于任务组中。如果我在任务组之外执行此操作(只是发布中的常规 powershell 任务),那么它就可以工作。当我将该值传递给任务组参数时,它失败了。请参阅下面的日志。

2017-08-24T12:58:50.5643742Z Generating script.
2017-08-24T12:58:50.7206133Z Formatted command: . 'C:\agent_work\r5\a\RCV\deploys\uxforms\Deploy-ToUxForms.ps1' -targetHost $(test_host)
2017-08-24T12:58:50.7206133Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File "C:\agent_work\_temp\baf9f7b8-2de2-4760-8cfd-67cd530801ed.ps1"
2017-08-24T12:58:50.7206133Z ##[error]test_host : The term 'test_host' is not recognized as the name of a cmdlet, function, script 
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct 
and try again.

At C:\agent_work\_temp\baf9f7b8-2de2-4760-8cfd-67cd530801ed.ps1:2 char:79
+ . 'C:\agent_work\r5\a\RCV\deploys\uxforms\Deploy-ToUxForms.ps1' -targetHost $(te ...
+                                                                               ~~
    + CategoryInfo          : ObjectNotFound: (test_host:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException

谢谢

重新创建了所有任务组和变量,现在可以使用了。