gerritexec: continuous integration one-liner

gerritexec is a command line tool listening to gerrit on a designated project. On each new patchset, it will:

  • git clone the project
  • git pull the patchset
  • cd in the git tree and run a script
  • positively review the patchset ( +1 ) if the program exit(0)
  • negatively review the patchset ( -1 ) otherwise

For instance It can be used to run the integration tests found in the git tree of the stackforge/puppet-ceph project:

GEM_HOME=~/.gems gerritexec --hostname \
           --username puppetceph \
           --script ' ( bundle install ; bundle exec rake spec:system ) > /tmp/out 2>&1 ; r=$? ; pastebinit /tmp/out ; exit $r #' \
           --project stackforge/puppet-ceph

Larger projects should consider using zuul or a gerrit jenkins plugin.

Using a virgin Ubuntu 12.04.3, it can be installed as follows:

sudo apt-get install python-pip git ruby-bundler libxml2-dev libxslt-dev
sudo pip install gerritexec

Assuming the ssh private key for the puppetceph user is found in ~/.ssh/id_rsa and that it is a service user able to review the stackforge/puppet-ceph project, gerritexec can be run as follows:

gerritexec --hostname \
           --verbose \
           --username puppetceph \
           --script 'bundle exec rake spec:system' \
           --project stackforge/puppet-ceph

It is better run from a screen to capture the output generated by –verbose and help with debugging should a problem occur.

This entry was posted in ceph, gerrit, puppet. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>