I want to set a variable during build, which I can then check during release. Below is what I have tried after doing my research.
Add a variable to the build:
In the build pipeline, add a "Powershell Script" Task with an inline script like this:
Write-Output "##vso[task.setvariable variable=SkipRelease;isOutput=true]true"
In the release, add a "Powershell script" with an inline script like this:
$skipRelease = $env:SkipRelease
Write-Output "SkipRelease variable is: $skipRelease"
I have tried several variations of this, reading the SkipRelease variable:
$skipRelease = "$(Build.DefinitionName.SkipRelease)"
...
$skipRelease = $(SkipRelease)
...
$skipRelease = $($env:SkipRelease)
None of them work, SkipRelease is either not defined or empty, depending on which method I use - determined by looking in the logs.
Can I check if the SkipRelease variable is actually by the build? How can I read it from the release?
Instead of pipeline variables use build tags.
For example, add a build tag named DeployApplication
to a build that should trigger a release:
echo "##vso[build.addbuildtag]DeployApplication"
Tag will be added to the build:
Then in the release artifacts configure a Continuous deployment trigger based on the branches and the build tags as follows: