Reputation: 163
So I have been working off of master for a while, and just recently added a 'release' branch that I will be working off of from now on.
In my Release Pipeline I have a PowerShell script that sets a custom variable using predefined variables.
$branchName = $Env:BUILD_SOURCEBRANCHNAME
$buildNumber = $Env:BUILD_BUILDNUMBER
$release = $branchName + "." + $buildNumber.ToString()
$pipeline.variables.NameVar.value = $release
If I push code to my release branch, this script will run at the end of my pipeline, and the variable should be changed to release.xxxx
, but it is changed to master.xxxx
.
Is there a reason the build variable build.sourcebranchname
does not return my release branch name, and instead returns master? The build.buildnumber
variable returns the correct value.
Upvotes: 0
Views: 1578
Reputation: 163
So I figured out my issue. After adding the new release branch, I needed to edit my build pipeline to setup multiple branches. Basically following this doc from Microsoft.
Adding release/*
as a branch filter allowed the build pipeline to build on the release branch, and not just the master branch. From that point on, when I used the build variables in my release pipeline, they all returned the proper value.
Upvotes: 0
Reputation: 31003
Try to go to Get sources
and check whether you select the correct branch.
I've tested your script and it returned expected result:
Upvotes: 1