TTCG
TTCG

Reputation: 9113

Azure DevOps: How to set the value of the Variable in Variable Group

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:

I added the Variable Group and Link it in my Build pipeline.

enter image description here

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.

enter image description here

Could you please suggest me how I could set this value in the Build Pipeline?

Upvotes: 4

Views: 3969

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

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

enter image description here

The above it's the behavior of the logging command ##vso[task.setvariable variable] and not only to the variable group.

Upvotes: 4

Related Questions