Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .README
Octocat-spinner-32 lib
Octocat-spinner-32 models
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rbenv-version
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 git-notes.pluginspec
README.md

Add git-notes with Jenkins build status!

This is a pure Ruby Jenkins plugin which annotates git commits with Jenkins build information using the awesome git-notes functionality.

Background

Haven't heard of git-notes? You're not alone. Although first proposed in 2007 and released in 1.6.6, many still haven't heard of the feature. In short, git-notes allows namespaced data to be natively associated with a commit after-the-fact.

So git-notes seemed like it might a good place to store meta-information like build status, both for human and programmatic consumption, but then GitHub made it irresistible by displaying the notes prominently on commit pages. Ever wanted to see the build status of the last commit in a pull request?

And since Jenkins made it simple to try out new ideas like this, it was an easy decision to start work on this plugin!

Prerequisites

  • Git version 1.7.1 or greater needs to be installed on the Jenkins master.

Install

  1. Get Jenkins.

  2. Install the ruby-runtime plugin and the git-notes plugin.

  3. Restart Jenkins.

install the ruby-runtime and git-notes plugins

Use

With the git-notes plugin installed in Jenkins, you simply check the "Publish build result as git-notes" box in the publish section of the build config:

check the publish git-notes box

Your commits will then get the latest build status, which GitHub will display in a pretty yellow box at the bottom of the commit page and under the "jenkins" namespace:

profit!

As you can see, the format of the notes is JSON. Here is an example which has been marked up with comments for clarity:

{
  "built_on": "master",                 /* name of node that build ran on */
  "duration": 1.786,                    /* number of seconds that the build took */
  "full_display_name": "junk #45",      /* name of the build, project + number */
  "id": "2012-03-29_09-46-01",          /* unique ID for the build */
  "number": 45,                         /* project build sequence number */
  "result": "SUCCESS",                  /* result string: ABORTED|FAILURE|NOT_BUILT|SUCCESS|UNSTABLE */
  "status_message": "stable",           /* recent project status */
  "time": "2012-03-29 09:46:01 -0400",  /* time that build was scheduled */
  "url": "job/junk/45/"                 /* build URL, relative to root */
}

Develop

Interested in contributing to the Jenkins git-notes plugin? Great! Start here.

Start the development server and set up a build config to test with:

bundle install
bundle exec jpi server
open http://localhost:8080

Run the tests:

bundle exec rspec
Something went wrong with that request. Please try again.