0
votes

I have created a build with an Ubuntu agent, and I'm trying to access my pipeline variables through a powershell task, but it always returns an empty value. By contrast, when I run the same script on a Windows agent it can get the value correctly.

The script that I use is:

Write-Host "My Variable is $env:URLAPI"
Write-Host "My Another Variable is $env:Build.BuildNumber"

I just want to know why this works on Windows Agent and not on the Ubuntu Agent.

Thank you

1
I do not think you can run PowerShell script on Ubuntu directly. In Windows, you can output the environment variable like $env:var, but in Ubuntu, you should do that like $var.Charles Xu
why not? there is a powershell task that work in ubuntu, and it would require you to use $env:var_name. why would you use it like $var? it wont work4c74356b41
Try this $ {env: Build.BuildNumber} = '170.42'; Write-Host "My other variable is $ {env: Build.BuildNumber}" . Tested on Linux 4.15.0-46-generic # 49-Ubuntu SMP Wed Feb 6, 09:33:07 UTC 2019 in PowerShell 6.1.3 Core.Andrei Odegov

1 Answers

0
votes

You can run powershell in linux too, I solved the problem there was something i didn't know.. In linux machine the pipelines variables convert the string in uppercase, so i just changed for $env:BUILD.BUILDNUMBER and it works