问题
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:
- 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")
- 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