We have a Git repository in TFS (2017.3) and our builds run on Jenkins.
We want to implement in the Pull Request a build validation so we created a build definition that queue a Jenkins job and in the "Job parameters" we enter
BRANCH=$(System.PullRequest.SourceBranch)
:
The issue is that in the TFS Get Sources step TFS creates a temporarily merged branch to check the PR, but the System.PullRequest.SourceBranch
returns the PR source branch (e.g. feature branch) and not the merged branch, so the Jenkins job runs on the source branch and not check the PR.
Can we send to Jenkins the merged branch or we must to do the merge in the Jenkins job?
UPDATE:
I see that the variable Build.SourceBranch
returns the merged branch but it looks likes the Jenkins job not know this branch. I checked now in the agent and the Git is in Detached HEAD, so I assume there is no option to get from outside the agent (even if the agent was created a new branch - "merged branch" it's only local). any idea?
BRANCH=$(...)
turns out without quotes in that case. - David