README.md

Poor man's CI

This project tries to tie together Pagure with Jenkins. The goal is simple: every time a pull request is created or updated, trigger a build in Jenkins to verify the pull request does not break anything.

How does it work

Pagure is really quite chatty: you can configure the project to announce pretty much everything via Fedmsg. The Fedora Infrastructure instance of Jenkins also has a messaging plugin. Both services provide API to query more information from and to submit requests.

Setup

The setup is a bit painful:

1) In Pagure, go to project settings and enable Fedmsg integration. Then generate an API key with permission to post flags to pull requests.

2) Update configuration of Jenkins job to accept two string parameters REPO and BRANCH.

3) In the Jenkins script running tests add a snippet to merge the PR (if provided). This seems to do nicely:

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

4) Enable remote build trigger and set up an authentication token. Enable Fedmsg as post build action.

5) Get this server running somewhere. You may need to install fedmsg-hub as well. There is a COPR repo with RPM build for Fedora 23 available.

6) Update the configuration in /etc/fedmsg.d/poormanci.py (there is an example in this repo). The config needs to contain the API keys created above.

7) Create a pull request against the project and hope for the best.

To debug this monstrosity, I found journalctl -f -u fedmsg-hub.service to be extremely helpful.

Caveats

The configuration is rather simplistic right now. It assumes that the project has same name in both Pagure and Jenkins. Also, to change the configuration you actually need to have superuser access to the machine running the service.

It currently hard codes which instances of Pagure and Jenkins it is working with.

Attribution

A lot of the code is stolen from pdc-updater and the-new-hotness. Especially the packaging part.