1

I have a function which will return a result. I am setting that result as an environment value in a pipeline. When I am invoking environment variable it's not printing the next two lines.

Write-Host "Before env : $result"
write-host "##vso[task.setvariable variable=message]$result"
[![enter code here][1]][1]

In other stage I invoked message other variable but it's not printing the next two lines.

write-host "After env :  $(message)"
[![enter code here][2]][2]

My only challenge was not getting the last two lines which is ASDB_REPORT / ASDB_REPORT_TEST

2
  • Hi Bala, Does my answer work? Please check it and kindly let me know the result. Commented May 11, 2021 at 8:38
  • No , I can able to fetch the environment values in pipeline . But i can't able to append environment values more than 1 line Commented May 16, 2021 at 23:00

1 Answer 1

2

If you set an environment variable with PowerShell in release pipeline, please refer to this doc: Set variables in scripts.

$result = 'crushed tomatoes'

Write-Host "##vso[task.setvariable variable=sauce]$result"

# Write-Host "sauce: $(sauce)"

Please note that "Subsequent steps will also have the pipeline variable added to their environment. You cannot use the variable in the step that it is defined." Thus you could access to the new variable with macro syntax and in tasks as environment variables.

Write-Host "sauce: $(sauce)"

Write-Host "my environment variable is $env:SAUCE"

However, you can't pass a variable from one job to another job or from one stage to another stage of release pipeline, unless you use multi-stages YAML. Please refer to Set a multi-job output variable for details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.