This is a service that automates running your test suite on incoming pull requests before they are actually merged. Think Travis CI but for Pagure and using you own instance of Jenkins.


How to set it up

The set-up needs to happen here, in Pagure and in Jenkins.

Setting up the integration

Just hit the add button in top right corner and put in all the information.

How to set up Pagure

The message announcing a new or edited pull request is sent automatically. You just need to create an authentication token that can add flags to pull requests.

How to set up Jenkins

The job must be parametrized and define two string parameters: REPO and BRANCH. These will have the information on what the pull request proposes to merge. There is another parameter BRANCH_TO that, if supplied, will contain name of branch into which the pull request should be merged.

In your test script you need to make sure the change is checked out and merged to master. The following snippet can do that.

if [ -n "$REPO" -a -n "$BRANCH" ]; then
    git remote rm proposed || true
    git remote add proposed "$REPO"
    git fetch proposed
    git checkout "origin/${BRANCH_TO:-master}"
    git merge --no-ff "proposed/$BRANCH" -m "Merge PR"

In order for this service to be able to trigger Jenkins jobs, you need to enable remote triggers and set a authentication token.

The last change in Jenkins is configuration to report status. With Fedmsg you just need to enable the plugin. If you use the Notification plugin, add a nofitication pointing to the URL copied from this service. Set it to send the message in JSON format when the job is finalized.

You may need to set it to send 1 log line to avoid crashing.

Tips & Tricks

If you use the same Jenkins job for testing pushes to your repository and check for updates via polling, make sure to restrict branches to only check origin. Otherwise the tests will run even on a push the repository from which you last checked a pull request.