Closed
Description
Agent version and platform
Version of your agent: 2.105.7
Windows Server 2012 R2
VSTS type and version
On-Prem TFS 2017
What's not working?
The Build.SourceBranchName
variable does not include full branch name, if branch name includes forward slash like feature/mynewfeature
or bug/bug1234
.
If the branch includes a forward slash, then Build.SourceBranchName
will only include the last segment: mynewfeature
or bug1234
.
Actual:
Build.SourceBranch | Build.SourceBranchName |
---|---|
refs/heads/feature/mynewfeature |
mynewfeature |
refs/heads/bug/bug1234 |
bug1234 |
Expected:
Build.SourceBranch | Build.SourceBranchName |
---|---|
refs/heads/feature/mynewfeature |
feature/mynewfeature |
refs/heads/bug/bug1234 |
bug/bug1234 |
Build scripts
You can reproduce by creating a branch called feature/something
and have a build definition with a singe powershell script:
Write-Output "BUILD_BUILDNUMBER = ${env:BUILD_BUILDNUMBER}"
Write-Output "BUILD_SOURCEBRANCH= ${env:BUILD_SOURCEBRANCH}"
Write-Output "BUILD_SOURCEBRANCHNAME= ${env:BUILD_SOURCEBRANCHNAME}"
Write-Output "BUILD_SOURCESDIRECTORY= ${env:BUILD_SOURCESDIRECTORY}"
Write-Output "BUILD_SOURCEVERSION= ${env:BUILD_SOURCEVERSION}"
Output
2017-03-07T12:17:43.4744817Z ##[section]Starting: PowerShell Script
2017-03-07T12:17:43.6463541Z ##[command]. 'C:\Users\TFSBUILD\AppData\Local\Temp\3ed8057f-da6d-4ee2-9e51-04fb192d1677.ps1'
2017-03-07T12:17:44.9782144Z BUILD_BUILDNUMBER = mybuild_07
2017-03-07T12:17:44.9782144Z BUILD_SOURCEBRANCH= refs/heads/feature/something
2017-03-07T12:17:44.9782144Z BUILD_SOURCEBRANCHNAME= something
2017-03-07T12:17:44.9782144Z BUILD_SOURCESDIRECTORY= D:\B\A1\_work\17\s
2017-03-07T12:17:44.9782144Z BUILD_SOURCEVERSION= 264c7662370f39ef0db9ab2c46489a686ac22724
2017-03-07T12:17:45.1344955Z ##[section]Finishing: PowerShell Script
Expected output
...
2017-03-07T12:17:44.9782144Z BUILD_SOURCEBRANCH= refs/heads/feature/something
2017-03-07T12:17:44.9782144Z BUILD_SOURCEBRANCHNAME= feature/something
...
Metadata
Assignees
Labels
No labels
Activity