问题
I am trying to overwrite the value of the variable from Variable Group in Azure DevOps and it's not working. It's always showing the original value.
I wrote my Powershell scripts as shown by these links:
- Microsoft
- StackOverflow
I added the Variable Group and Link it in my Build pipeline.
I wrote the following scripts in Power Shell Script task.
Write-Host "Original BPOwner = $(BPOwner)"
Write-Host "Changing value of BPOwner to Bright Ran"
Write-Host "##vso[task.setvariable variable=BPOwner;]Bright Ran"
Write-Host "New BPOwner = $(BPOwner)"
However, in the Build, it's always showing the original value and it's never changed to the value I want to set.
Could you please suggest me how I could set this value in the Build Pipeline?
回答1:
The new value available only in the next tasks, not in the same task when you change the value. for example, I added another PS task with Write-Host "New BPOwner = $(BPOwner)"
:
The above it's the behavior of the logging command ##vso[task.setvariable variable]
and not only to the variable group.
来源:https://stackoverflow.com/questions/57674793/azure-devops-how-to-set-the-value-of-the-variable-in-variable-group