Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Documentation about output variables in tasks seems like work in progress #5134

Open
1 of 4 tasks
eloekset opened this issue Mar 3, 2025 · 1 comment
Open
1 of 4 tasks

Comments

@eloekset
Copy link

eloekset commented Mar 3, 2025

What happened?

I'm trying to figure out how to pass a variable from one PowerShell task to another within the same Azure Release Pipeline. After struggling a lot, I clicked the link by the "Output Variables" -> "Referance name" field, which takes me to this documentation page: https://github.com/Microsoft/azure-pipelines-agent/blob/master/docs/preview/outputvariable.md

Read this page and look at the formulations. "Customer can change it", sounds like an internal description for someone at Microsoft. A heading "TODO" indicates that this page is work in progress. "I am not sure how are we going to generate Job ref name, ..." sounds like an internal note to developers.

Versions

4.251.0, Microsoft Windows Server 2019, 10.0.17763

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

No response

Version controll system

No response

Relevant log output

2025-02-10T13:55:40.0440914Z ##[section]Starting: Use output variable from first task
2025-02-10T13:55:40.0448978Z ==============================================================================
2025-02-10T13:55:40.0449322Z Task         : PowerShell
2025-02-10T13:55:40.0449415Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2025-02-10T13:55:40.0449574Z Version      : 2.247.1
2025-02-10T13:55:40.0449664Z Author       : Microsoft Corporation
2025-02-10T13:55:40.0449750Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2025-02-10T13:55:40.0449875Z ==============================================================================
2025-02-10T13:55:41.2476486Z Generating script.
2025-02-10T13:55:41.2999081Z ========================== Starting Command Output ===========================
2025-02-10T13:55:41.3368808Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\c6bf610a-d974-4181-b4ca-bd30a07f0dd3.ps1'"
2025-02-10T13:55:42.0659366Z somevariable : The term 'somevariable' is not recognized as the name of a cmdlet, function, script file, or operable 
2025-02-10T13:55:42.0660290Z program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2025-02-10T13:55:42.0660878Z At D:\a\_temp\c6bf610a-d974-4181-b4ca-bd30a07f0dd3.ps1:4 char:59
2025-02-10T13:55:42.0661214Z + ... te-Output "Value of variable set in previous task is $(somevariable)"
2025-02-10T13:55:42.0661496Z +                                                            ~~~~~~~~~~~~
2025-02-10T13:55:42.0661781Z     + CategoryInfo          : ObjectNotFound: (somevariable:String) [], ParentContainsErrorRecordException
2025-02-10T13:55:42.0662880Z     + FullyQualifiedErrorId : CommandNotFoundException
2025-02-10T13:55:42.0666873Z  
2025-02-10T13:55:42.3382609Z ##[error]PowerShell exited with code '1'.
2025-02-10T13:55:42.4047498Z ##[section]Finishing: Use output variable from first task
@eloekset
Copy link
Author

eloekset commented Mar 3, 2025

I gave up figuring out how to pass variables between tasks, and came up with the idea to write variables to files instead.

PowerShell Task 1 Inline Script:
Write-Output "Setting a PowerShell variable to some value"
$some_variable = "some value"
Write-Output "Writing some value to a file"
s o m e v a r i a b l e | O u t F i l e F i l e P a t h " (System.DefaultWorkingDirectory)\some_variable.txt"

PowerShell Task 2 Inline Script:
s o m e v a r i a b l e = G e t C o n t e n t P a t h " (System.DefaultWorkingDirectory)\some_variable.txt"
Write-Output "Value of some variable read from file is $some_variable"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant