VSTS Nested Variables

帅比萌擦擦* 提交于 2021-01-27 20:04:01

问题


I'm trying to accomplish a cascading variable, where when one design time variable is set, it cascades to other variables. Is this possible? I've tried with dot notation, I've tried without dot notation, and I've tried to do it in the task:

I also tried this task plugin, but my agents are on 2.0 and the task doesn't run.

Variable Toolbox Task

Any ideas?

Answer:

You can override these variables at the environment level. I will have to expand these variables in my script manually and then set them to the resolved values in this script.


回答1:


You can set the variable value through Logging Command during the build:

  1. Add PowerShell task

Script: (Need to use _ instead if the variable contains ., such as Server.Dev=> Server_Dev)

$v= [Environment]::GetEnvironmentVariable("Server_$env:Environment")
Write-Host ("##vso[task.setvariable variable=Server;]$v")
  1. Then the following tasks could use Server variable with corresponding value



回答2:


Instead of having different variables for each environment, use the same variable but override it at the environment level.



来源:https://stackoverflow.com/questions/46736978/vsts-nested-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!