microsoft / azure-pipelines-agent

Azure Pipelines Agent 🚀
MIT License
1.71k stars 862 forks source link

Set a variable both as local as well as output. #4108

Open jessehouwing opened 1 year ago

jessehouwing commented 1 year ago

Version of your agent? 2.213.2

OS of the machine running the agent? Windows

Azure DevOps Type and Version

dev.azure.com If dev.azure.com, what is your organization name? https://dev.azure.com/jessehouwing-dev

I have a variable that I set in a task Extension.Version. When I pass the isOutput=true, I expect it to register an output variable. When I pass isOutput=false I expect it to register a local variable. When I run both commands in succession, I expect both the output and the local variable to be set.

This scenario is important to support backwards compatibility when introducing output variables to a task that previously didn't have one, without breaking my users.

The Bug

This doesn't work, however, when the task explicitly declares the output variable in the task.json, which completely seems to make the isOutput=false to be ignored.

    console.log("Setting local variable 'Extension.Version'.");
    tl.setVariable("Extension.Version", version, false, false);
    console.log("Setting output variable '{{StepName}}.Extension.Version'.");
    tl.setVariable("Extension.Version", version, false, true);
##[debug]setBuildNumber=false
##[debug]setOutputFlag=false
##[debug]outputVariable=MyExtension.Version
##[warning]Using of deprecated 'outputVariable' parameter. Remove this parameter and use 'setOutputFlag: true' and 'name: {{Stepname}}' on this step and reference '{{StepName.Extension.Version}}' in a future step instead.
##[debug]Processed: ##vso[task.issue type=warning;]Using of deprecated 'outputVariable' parameter. Remove this parameter and use 'setOutputFlag: true' and 'name: {{Stepname}}' on this step and reference '{{StepName.Extension.Version}}' in a future step instead.
##[debug]set MyExtension.Version=3.0.11
##[debug]Processed: ##vso[task.setvariable variable=MyExtension.Version;isOutput=false;issecret=false;]3.0.11
##[warning]Using deprecated variable conversions. Use 'setOutputFlag: true' and 'name: {{Stepname}}' on this step and reference '{{StepName.Extension.Version}}' in a future step instead.
##[debug]Processed: ##vso[task.issue type=warning;]Using deprecated variable conversions. Use 'setOutputFlag: true' and 'name: {{Stepname}}' on this step and reference '{{StepName.Extension.Version}}' in a future step instead.
Setting variable 'Extension.Version'.
##[debug]set Extension.Version=3.0.11
##[debug]Processed: ##vso[task.setvariable variable=Extension.Version;isOutput=false;issecret=false;]3.0.11
##[debug]task result: Succeeded
##[debug]Processed: ##vso[task.complete result=Succeeded;]tfx exited with return code: 0

Results in:

Direct $(Extension.Version)
Output 3.0.11 // $(Query.Extension.Version)

Removing the OutputVariables section from the task.json results in:

Direct 3.0.11 // $(Extension.Version)
Output 3.0.11 // $(Query.Extension.Version)
kirill-ivlev commented 1 year ago

Hi @jessehouwing, thanks for reporting! We are working on more prioritized issues at the moment but will get back to this one soon.

github-actions[bot] commented 1 year ago

This issue has had no activity in 180 days. Please comment if it is not actually stale

jessehouwing commented 1 year ago

Still issue.

github-actions[bot] commented 7 months ago

This issue has had no activity in 180 days. Please comment if it is not actually stale

jessehouwing commented 7 months ago

Still issue

github-actions[bot] commented 1 month ago

This issue has had no activity in 180 days. Please comment if it is not actually stale

jessehouwing commented 1 month ago

Still an issue