question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected ##vso[task.setvariable]value behavior with Task Groups

See original GitHub issue

There’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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dekacommented, Dec 28, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found