Set output variable in a Powershell VSTS Build Task
I have value in my artifact files. I set it in this post. So now I can use it. I will get it almost the same way - using powershell.
Reading file content with powershell is easy it's just one line
$userNotes = Get-Content $path
Trick is to return content stored in local variable. This great article show me the direction where should I look and there is a possibility to talk with VSTS using build in commands/functions. Full specification you can find in GitHub VSTS tasks documentation.
Setting variable in powershell script looks like this:
Write-Output ("##vso[task.setvariable variable=MyVariableName;]$localVariableWithSomeData")
I added in my example second scrip just to show that the value is set as I expect.
Reading file content with powershell is easy it's just one line
$userNotes = Get-Content $path
Trick is to return content stored in local variable. This great article show me the direction where should I look and there is a possibility to talk with VSTS using build in commands/functions. Full specification you can find in GitHub VSTS tasks documentation.
Setting variable in powershell script looks like this:
Write-Output ("##vso[task.setvariable variable=MyVariableName;]$localVariableWithSomeData")
I added in my example second scrip just to show that the value is set as I expect.
Comments