A JBoss Project
Red Hat

Exploring how to build from pull requests in Jenkins for continuous feedback

posted by Nick Boldt on Feb 25, 2016.

ci cd releng devstudio jbosstools


A couple weeks ago, I started prototyping how we could enable building PRs submitted against the JBoss Tools projects, in order to more easily create installable update sites (Eclipse p2 repositories) from pull requests. This is part of our new thrust to provide more continuous integration and deployment, to better be able to release software faster.


Verify a commit before pushing it to master. Continuous feedback. Easier installation testing. Ability to share a proposed change, including the whole built update site so peer reviews can be done against binaries as well as sources.

Job Config

Here’s how to configure a job to use the Github Pull Request Builder Plugin:

  1. add a sha1 parameter

  2. pull from git using this remote config:

    <refspec>+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*</refspec>
  3. pull from git using this branch:

  4. enable Github Pull Request Trigger

    <org.jenkinsci.plugins.ghprb.GhprbTrigger plugin="ghprb@1.20.1">
      <spec>H/5 * * * *</spec>
      <cron>H/5 * * * *</cron>

Job Steps & Deployment

One way to react to a successful build of a PR is to simply deploy to a different URL than normal builds.

For example, a job could be set up such that if ${ghprbPullId} is defined, a deploy-pr profile is used; if not, the usual deploy-to-jboss.org profile could instead be used.

mvn deploy -Pdeploy-pr

However, we might also want a different sequence of build steps in a job. Normally, we orchestrate jobs to build, deploy, & test. But for a PR build, we might instead want to sequence the steps as build+test, and only deploy if successful.

So perhaps instead of parameterizing the job to publish to snapshots/pulls/ or snapshots/builds/, we might instead parameterize the maven lifecycle steps:

if [[ ! ${ghprbPullId} ]]; then
	mvnStep1="clean install -DskipTests" # build without tests
	mvnStep2="deploy -Pdeploy-to-jboss.org" # deploy if p2diff or SHA check shows difference into /builds/ folder
	mvnStep3="verify" # run tests & fail job if problems found
	mvnStep1="clean deploy -Pdeploy-pr" # build and test, then deploy to /pulls/ folder if successful or fail if tests fail

Current experiment is here (sorry, VPN required):

Questions / TODOs

  • Can whitelists be set up programmatically? (git committerIDs which can trigger a build automatically)

  • Can admins be set up programmatically? (git committerIDs which can approve a PR to be built, rather than ANY submitted PR, to prevent malicious attacks)

  • How do we roll up a low-level project’s pull request build into a larger stack of projects or products? Do we rebuild everything that’s downstream? Or just the aggregates/product?

  • How aggressively should we purge pull request builds?

  • When running matrix jobs, what happens when one part of the job is running, another is waiting, and a force-push updated to a PR arrives? (Answer: the waiting configurations will fail because the expected SHA no longer exists, having been force-replaced.)

Latest posts

JBoss Tools 4.29.0.Final for Eclipse 2023-09

by Stéphane Bouchet on Nov 02, 2023.

JBoss Tools 4.28.0.Final for Eclipse 2023-06

by Stéphane Bouchet on Jul 03, 2023.

JBoss Tools for Eclipse 2023-06M2

by Stéphane Bouchet on Jun 05, 2023.

JBoss Tools 4.27.0.Final for Eclipse 2023-03

by Stéphane Bouchet on Apr 07, 2023.

JBoss Tools for Eclipse 2023-03M3

by Stéphane Bouchet on Mar 10, 2023.

Looking for older articles ? See the Archived entries.
back to top