Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

GitHub Pull-Requests for specific merge branch #3791

uartie ·

Is there a way to configure QB to only process pull-requests that are destined for a specific branch?

When user submits a pull-request, they request it to be merged to a specific destination branch (which is indicated at top of pull-request page on GitHub; e.g. https://github.com/01org/libva-utils/pull/44). We want to be able to have QB only process pull-requests for, say, "master" branch and not feature branches.

  • replies 10
  • views 3593
  • stars 1
robinshen ADMIN ·

Please submit an improvement request for this at track.pmease.com

uartie ·
uartie ·

Almost, but not quite...

The below script is somewhat of a hack, but it can be used as the "Execute Condition" in a Composition step. However, for HEAD pull-requests, the build check status still gets uploaded to all GitHub PRs, regardless of pr.base.ref. I'm not sure how that can be circumvented.

groovy:
repo = repositories.get("source");
client = repo.newGitHubClient();
service = new org.eclipse.egit.github.core.service.PullRequestService(client);
rid = org.eclipse.egit.github.core.RepositoryId.createFromId(repo.generateId());
id = Integer.parseInt(repo.actualBranch.split("/")[2]);
pr = service.getPullRequest(rid, id);
base = pr.base;
return base.ref == "master";
robinshen ADMIN ·

Have you tried to use this as build condition (general setting of configuration) instead of step execute condition?

uartie ·

Yes, I tried that. However, the build condition is only applied for scheduled trigger and not manual trigger. Also, this causes open pull-requests (that pass this condition) to get built on every scheduled trigger, regardless if it was built in previous trigger and no change to pr.

uartie ·

I suppose in build condition, it could be "If all specified criteria are satisfied" with criteria's set to "if changes found in reference repositories" and "if specified script evaluates to true"... that would likely deal with the latter issue I described. But still have issue with "manual" trigger.

robinshen ADMIN ·

You may use below pre-queue script in general setting of configuration to tell QB to respect build condition even for manual build:
request.respectBuildCondition=true

uartie ·

With the above techniques, QB still appears to ignore the build condition if no builds have been generated before (for manual trigger). Does this have something to do with the pre-queue script not being applied on first build?

robinshen ADMIN ·
uartie ·

Outstanding! It works perfectly as expected. Thank You!