Hi,
I have used the below code in bash to create an environment variable to be used in another step.
echo 'export VERY_IMPORTANT=$("somevalue")' >> $BASH_ENV
However I cannot seem to find a way to do this in PowerShell. Is this possible?
Thanks!
1 Like
I have the same issue and have also tried writing the environment variable to the PowerShell profile which doesn’t seem to be executed on subsequent steps.
New-Item $Profile.CurrentUserAllHosts -Force
Add-Content -Path $Profile.CurrentUserAllHosts -Value '$Env:BUILD_VERSION = "1.0.0"'
The following returns null when run in a subsequent step.
$Env:$BUILD_VERSION
Update 8/12:
A coworker found this post and rubber ducked me into realizing I had a dumb syntax error while calling the env var.
This works as expected provided you’re calling the var correctly with
$Env:BUILD_VERSION
cdhunt
June 2, 2022, 10:24am
3
That is similar to how I have it working. What path does that resolve to?