Build trigger branch filter for pull requests
My build trigger works when the branch filter is +:*
However, I only want it to only trigger when a pull request is created and on commits to a pull request.
I changed the branch filter to +:refs/pull/*/head. Now it indicates that changes are pending but it does not run the build when I create a new pull request.
How can I trigger the build for only pull requests?
Please sign in to leave a comment.
Hi William,
please ensure that the Branch specification in the VCS configuration (not on the trigger) also includes +:refs/pull/*/head. If you do, could you please share a screenshot of the VCS configuration and the VCS Trigger configuration to see whether there is something wrong?
The most common scenario is that as you have taken out the trigger for all branches which aren't pull requests, you are picking up commits from other branches and thus it doesn't trigger.
I do that but the trigger does not activate
Hi William,
thanks for the screenshots, just for confirmation, which version are you running?
TeamCity Enterprise 2017.2 (build 50574)
Hi William,
this happens because branch filter in VCS trigger expects a logical branch name (https://confluence.jetbrains.com/display/TCD10/Working+with+Feature+Branches#WorkingwithFeatureBranches-Logicalbranchname). With your branch specification a logical branch name is just a number of the pull request, not the full ref name (XXX instead of refs/pull/XXX/head). To make it work, change the branch specification in VCS root settings to: +:(refs/pull/*/head)
I see. I can set the logical name by using parentheses. Thanks Dmitry.
Now my branch shows up as refs/pull/2/head in the UI. Is there anyway to set the logical name of this pull request to PR2?
Branch names are automatically generated from the branch specification. For shorter names you can use the information here: https://confluence.jetbrains.com/display/TCD10/Working+with+Feature+Branches#WorkingwithFeatureBranches-Logicalbranchname
and how should it be in the case of pull request..?
Hi Mickey,
what do you mean?
let me refrase it ....
i have a vcs root, which i want to trgger the pr on this vcs and to show only the head branch of the pr, not the base branch nor the pr number.
i want the developer who make change will get indication on the feature he created and the pr. but doing that by looking on the builds list.
is that possible?
Hi Mickey,
I'm afraid not just now. PRs are at the moment just regular branches, so while TeamCity can keep track of the branches and their trees, each branch works on its own, so TeamCity will only show the branch it has worked on. Take into account that you are also requesting that the displayed branch for a build is actually a different branch than the actual one where the commit happened.
This said, we are working on supporting PRs as a special entity directly: https://youtrack.jetbrains.com/issue/TW-48771, and that will improve visibility and control over the parent branch. It's going to take a while until that's available though, and I'm not sure displaying the head branch instead of the PR branch is being considered as an option, as it would hide actually useful information.
If you would still like to see this as an option, please open a request in our tracker for it.