microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.51k stars 2.62k forks source link

In a Task Group (Meta-Task) Write-Host "##vso[task.setvariable variable=someVar;]someValue" when the variable is used later within same task group it's back to the default value #8949

Closed W0GER closed 5 years ago

W0GER commented 6 years ago

Issue Description

In a Meta-Task (Task Group) In step 1 - PowerShell Script that executes: Write-Host "##vso[task.setvariable variable=PullRequestSourceBranchName]$pullRequestSourceBranchName" or Write-Host "##vso[task.setvariable variable=PullRequestSourceBranchName;]$pullRequestSourceBranchName"

In step 2 - reference the $PullRequestSourceBranchName However in that step the variable is back to it's default value

Environment

Capability name Capability value
Agent.ComputerName removed
Agent.HomeDirectory H:\Agents\DEP-1
Agent.Name 10.20.1.51-DEP-1
Agent.OS Windows_NT
Agent.OSArchitecture X64
Agent.OSVersion 10.0.14393
Agent.Version 2.142.1
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Users\svc-tfbuild-prod\AppData\Roaming
AWS_REGION us-east-1
Azure_Devops_PAT removed
Azure_Devops_User removed
Cmd C:\Windows\system32\cmd.exe
CommonProgramFiles C:\Program Files\Common Files
CommonProgramFiles(x86) C:\Program Files (x86)\Common Files
CommonProgramW6432 C:\Program Files\Common Files
COMPUTERNAME removed
ComSpec C:\Windows\system32\cmd.exe
DotNetFramework C:\Windows\Microsoft.NET\Framework64\v4.0.30319
DotNetFramework_2.0 C:\Windows\Microsoft.NET\Framework\v2.0.50727
DotNetFramework_2.0_x64 C:\Windows\Microsoft.NET\Framework64\v2.0.50727
DotNetFramework_3.0 C:\Windows\Microsoft.NET\Framework\v3.0
DotNetFramework_3.0_x64 C:\Windows\Microsoft.NET\Framework64\v3.0
DotNetFramework_3.5 C:\Windows\Microsoft.NET\Framework\v3.5
DotNetFramework_3.5_x64 C:\Windows\Microsoft.NET\Framework64\v3.5
DotNetFramework_4.7.0 C:\Windows\Microsoft.NET\Framework\v4.0.30319
DotNetFramework_4.7.0_x64 C:\Windows\Microsoft.NET\Framework64\v4.0.30319
HOMEDRIVE C:
HOMEPATH \Users**removed**
InteractiveSession False
LOCALAPPDATA C:\Users**removed**\AppData\Local
LOGONSERVER ###removed
MSBuild C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\
MSBuild_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\
MSBuild_15.0_x64 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\
MSBuild_2.0 C:\Windows\Microsoft.NET\Framework\v2.0.50727\
MSBuild_2.0_x64 C:\Windows\Microsoft.NET\Framework64\v2.0.50727\
MSBuild_3.5 C:\Windows\Microsoft.NET\Framework\v3.5\
MSBuild_3.5_x64 C:\Windows\Microsoft.NET\Framework64\v3.5\
MSBuild_4.0 C:\Windows\Microsoft.NET\Framework\v4.0.30319\
MSBuild_4.0_x64 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\
MSBuild_x64 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64\
node.js c:\Program Files\nodejs\node.exe
npm c:\Program Files\nodejs\npm.cmd
NUMBER_OF_PROCESSORS 4
OS Windows_NT
Path C:\Program Files\Packer;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\opscode\chef\bin\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;c:\Program Files\Amazon\AWSCLI\;c:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\opscode\chefdk\bin\;C:\Users\svc-tfbuild-prod\AppData\Local\Microsoft\WindowsApps;c:\Users\Administrator\AppData\Roaming\npm
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PowerShell 5.1.14393.1944
PROCESSOR_ARCHITECTURE AMD64
PROCESSOR_IDENTIFIER Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
PROCESSOR_LEVEL 6
PROCESSOR_REVISION 3f02
ProgramData C:\ProgramData
ProgramFiles C:\Program Files
ProgramFiles(x86) C:\Program Files (x86)
ProgramW6432 C:\Program Files
PSModulePath %ProgramFiles%\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell\;C:\opscode\chefdk\modules\
PUBLIC C:\Users\Public
SqlPackage C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130\SqlPackage.exe
SystemDrive C:
SystemRoot C:\Windows
TEMP C:\Users\SVC-TF~1\AppData\Local\Temp
TMP C:\Users\SVC-TF~1\AppData\Local\Temp
USERDNSDOMAIN removed
USERDOMAIN removed
USERDOMAIN_ROAMINGPROFILE removed
USERNAME removed
USERPROFILE C:\Users**removed**
VisualStudio C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\
VisualStudio_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\
VisualStudio_IDE C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\
VisualStudio_IDE_15.0 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\
VSTest C:\Program Files (x86)\Microsoft Visual Studio\2017\TestPro
windir C:\Windows

Task logs

From Step 1 2018-11-29T18:24:09.3993074Z ##[debug]Processed: ##vso[task.setvariable variable=PullRequestSourceBranchName]49466-POCRenderingSelection

From Step 2 Passing in the variable to a task, the variable value is back to the default.

Error logs

No error is thrown by Azure DevOps

omeshp commented 5 years ago

@W0GER When you say passing he variable value to step 2 Is it passed as input or are you reading the value task lib/from environment variables?

omeshp commented 5 years ago

@W0GER I am closing this issue since we didn't hear back from you. Please feel free to reopen if you are still facing the issue.