Unexpected ##vso[task.setvariable]value behavior with Task Groups
See original GitHub issueThere’s a behavior difference between a build containing two PowerShell tasks and a build containing a Task Group with the two same PowerShell tasks.
A build variable, Pass1
is set to build variable
.
Here are the two PowerShell inline scripts: Script 1
Write-Host "Here's $(Pass1)"
Write-Host "##vso[task.setvariable variable=Pass1;]HelloWorld"
Script 2 (Arguments: $(Pass1)
)
Write-Host "here's args: $args"
Write-Host "here's $(Pass1)"
Write-Host "here's $Env:Pass1"
Expected output for a build with two tasks (debug is true):
2016-11-18T15:43:08.9556405Z Here's build variable
2016-11-18T15:43:08.9836430Z ##[debug]Processed: ##vso[task.setvariable variable=Pass1;]HelloWorld
and
2016-11-18T15:43:09.8146428Z here's args: HelloWorld
2016-11-18T15:43:09.8486420Z here's HelloWorld
2016-11-18T15:43:09.8486420Z here's HelloWorld
Unexpected output for a build with a task group (debug = false
):
2016-11-18T15:44:24.1943543Z Here's build variable
and
2016-11-18T15:44:25.2743560Z here's args: build variable
2016-11-18T15:44:25.2753553Z here's build variable
2016-11-18T15:44:25.2793550Z here's HelloWorld
Unexpected output for a build with a task group (debug = true
):
Here's build variable
Processed: ##vso[task.setvariable variable=Pass1;]HelloWorld
and
here's args: build variable
here's build variable
here's HelloWorld
This was discovered when I upgraded my build to use Task Groups.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:11 (3 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, solution is not good “to set a variable inside Task Group and use it inside Task Group” ! It’s a workaround, not a good solution … •This is hacky scenario since any variable used inside of Task Group is exposed as an input which has to be filled with some value. Fill the input with the same variable name as the input7 •You may not need to define this variable in your Variables section, you will just need to make sure that you are setting it in one of your tasks in Task Group before consuming it in the same Task Group. •When the Task Group is expanded $(filePath) in tasks will be replaced by $(filePath) and you will be setting filePath in one of your tasks before consuming it.
@genesis-barrios you can look here, but the pictures are missing: https://docs.microsoft.com/en-us/archive/blogs/harshillodhi/vststfs-understanding-task-groups-and-its-various-use-cases-with-setvariable-logging-command