Type: Bug
Enter Task Name: any task with condition using the Build.SourceBranch variable
The variable Build.SourceBranch is documented to have this format for Git repositories: Git repo branch: refs/heads/master. This format was changed in the latest Azure Pipeline build agent so our builds are failing now.
See documentation: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
This is the condition we use in the S3Upload@1 task:
- task: S3Upload@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/development'))
Here is the log from the S3Upload@1 task which shows the format has changed:
Evaluating: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/development'))
Expanded: and(True, eq('development', 'refs/heads/development'))
Result: False
Second task:
Evaluating: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
Expanded: and(True, eq('development', 'refs/heads/master'))
Result: False
This was working with agent version: '2.174.1', image version: '20200827.1'.
Builds from such agents show successful S3Upload@1 and so the check was working correctly:
Starting: S3Upload
==============================================================================
Task : Amazon S3 Upload
Description : Upload file and folder content to an Amazon Simple Storage Service (S3) Bucket on AWS
Version : 1.7.0
...
All uploads to S3 completed
Finishing: S3Upload
This log confirms the format of the Build.SourceBranch variable:
Evaluating: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
Expanded: and(True, eq('refs/heads/development', 'refs/heads/master'))
Result: False
Yes, this is affecting me as well.. You can't change this without further notice.. All my company pipelines logic relies on this..
Same here!

everything is broken now!
@jozefizso @hdiass did anyone filled an issue for MS Support? Any outcome? I'm currently in contact with one of the support engineers, our case is 120092321004222, if any reference required.
In my observation, if the build is triggered manually again and debug.output set to true, the build is running well and condition is working as expected.
@jozefizso @hdiass did anyone filled an issue for MS Support? Any outcome? I'm currently in contact with one of the support engineers, our case is 120092321004222, if any reference required.
In my observation, if the build is triggered manually again and debug.output set to true, the build is running well and condition is working as expected.
I have a case open for this as well. 120091824006486
My agent version: '2.174.3'. I have the same condition in my pipeline:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/development'))
When the branch triggers the Azure Pipeline (in a CI manner) to build, the Build.SourceBranch would not have the refs/heads. Afterwards, I manually re-run the Azure Pipeline on the same branch, the Build.SourceBranch has the refs/heads prefix and satisfied the condition and built successfully.
I'm not sure if it's the manual trigger working or because I re-run build on the same branch for the second time. I repeated the same procedure twice, it seems to be consistent.
Hey folks - we are actively investigating this one. Since this isn't really a task-specific issue, I'm going to close here and we'll use https://developercommunity.visualstudio.com/content/problem/1192275/buildsourcebranch-no-longer-contains-git-reference.html for public tracking.
If you're being impacted, I'd recommend upvoting that thread. That will help it get the attention it needs (though to be clear, the product team is already looking into it)
@damccorm That will help it get the attention it needs
This is more then urgent priority issue now. We have issue with deployments for a week now and it disrupts our build pipeline.
Most helpful comment
Yes, this is affecting me as well.. You can't change this without further notice.. All my company pipelines logic relies on this..