I'm facing problems when I try to send an Environment variable between tasks using Powershell and Ubuntu hosts in Azure DevOps build pipelines.
To test and show this issue I have created a pipeline with the following:
-Two tasks are created, the first one is writing an environment variable:
$EnvVariable= "Value"
Write-Host "##vso[task.setvariable variable=EnvVariable;]$EnvVariable"
Write-Output "##vso[task.setvariable variable=EnvVariable;]$EnvVariable"
-The second Task is printing this value in the output:
Write-Host "env:EnvVariable : $($env:EnvVariable)"
Write-Host "ENV:EnvVariable : $($ENV:EnvVariable)"
Write-Output "env:EnvVariable : $($env:EnvVariable)"
Write-Output "ENV:EnvVariable : $($ENV:EnvVariable)"
-The output from this pipeline is looking good in Windows hosts, for example, using "vs2017-win2016" host I get this output:
env:EnvVariable : Value
ENV:EnvVariable : Value
env:EnvVariable : Value
ENV:EnvVariable : Value
-But when I execute this same pipeline in ubuntu hosts I'm not getting the expected output, here you have the output from second task executed in "ubuntu-18.04" build host:
env:EnvVariable :
ENV:EnvVariable :
env:EnvVariable :
ENV:EnvVariable :
As you can see there are no values from environment variable using the same tasks but in ubuntu hosts.
Just to double-check I've used Write-Output and Write-Host to check if the problem is caused by the requirement to use one of those and used env: and ENV: just to check if the case-sensitive variable name is the cause.
Thanks a lot for your time.