2

I have the following Powershel script that reads a text file. The value that is read is a value I want to pass as a variable to another step in the Azure Devops yml file

$data = Get-Content .\cluster_txt.txt
Write-Output $data

How can I access the value in $data in another task

1 Answer 1

2

You suppose to use logging command to create Azure Pipelines variable

Write-Host "##vso[task.setvariable variable=testvar;]$data"

and then in next task you can reffer to variable as

$(testvar)

or

$env:TESTVAR

Be aware that Azure Pipelines variable will not be available in the task you will create it. And if you need variable in another job or stage then you need output variable. Here you will find how to use it.

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.