Archive for March, 2011

WikiPublisher plugin for jenkins

March 27, 2011 1 comment

Sometimes, folks other than the developers are interested in the finding out about the different builds and the components (upstream projects) that are in a build. These other folks might be managers or non-programming types that don’t have access to Jenkins or are not interested in looking up things on Jenkins. They prefer to just see a website with all builds listed. This plugin attempts to satisfy that need.

We have an internal wiki site for sharing useful information and that seems as good a place as any to share information about current builds of projects. So, I’ve written the wiki publisher plugin that publishes your build name along with the names of all of its upstream builds to a wiki page you’ve configured. The names are also linked back to their corresponding build on Jenkins so that you can go from wiki to Jenkins to download artifacts or lookup changes.

This plugin is modeled after the Confluence Publisher plugin that is available for Jenkins. There are two separate configuration pages. In the global configuration page, you need to setup your list of wiki sites that you would like to publish to. I expect most will only have one site setup here but its nice to know you can add more. If your wiki site uses authentication, then you need to setup your username, password, domain for the user that Jenkins will use to publish to the wiki site. Make sure that this user has edit permission on the wiki pages. Also, I’ve only tested it against a wiki that authenticates against LDAP server. So there’s the possibility that it won’t work on other setups. One additional note of caution. Your wiki site may be using https but only use a self signed certificate. In that’s the case, then do not check the “use https” link or it won’t work.

Now that you have your wiki site setup, its time to configure your project to publish to the wiki site. Open up your project configuration page and you will see a new section to publish build results to a wiki. Here, select the wiki site your setup previously and enter the name of the page where the results are to be published. The plugin won’t create the page itself and you must go to your wiki and setup an empty page before running any builds.

This plugin uses the jwbf library for publishing to the wiki and that library has a dependency on log4j 1.2.14 or above. Unfortunately, Jenkins uses an older version and so on your Jenkins machine, you must setup the “java.endorsed.dirs” environment variable to point to a directory that contains log4j 1.2.14 or above.

Let me know if this plugin has been useful to you and thanks to the excellent Jenkins build tool.

WikiPublisher on Github

Tags: ,

major.minor plugin for Jenkins

March 27, 2011 Leave a comment

Recently, I’ve been tasked with setting up a build environment at work and we decided to go with Hudson and now Jenkins. I think the best part of Jenkins is its extensibility in the form of writing plugins to make it do exactly what you want. So my first plugin was to change the build numbers that Jenkins uses like #1, #2 etc. to something more meaningful for our scenario and so was born the major.minor plugin.

The premise of the plugin is quite simple. In our projects, we would like to see build names of the form major.minor.revision. We use subversion for source code management and so the revision number here refers to the svn revision number. The major and the minor numbers are configured when the build is initially setup and are initialized to 1 and 00 respectively. So, the first build name might be something like 1.00.23 if the svn revision at that point happened to be 23.

At some point down the line in the project cycle, we might like to increment the minor or major number and this can be done manually after a build by using already Jenkins feature to edit the build name. Since the plugin picks up the major and minor part of the build name from the previous build of the project, subsequent builds will now have the correct major and minor sections.

Now that the build name has been changed, when you browse through the builds directory for your project, it will be hard for you to figure out which build is what because Jenkins only creates directories using the build number like #2, #3 etc. and the date/time when the build was executed. To make it easier, the plugin also creates a new symbolic link with the build name in the builds directory. Now the Jenkins UI and builds directory matches and its easier for you to get to the right build.

When you enable this plugin, you get a new configuration section for your project. In this section, you will configure a regex to match build names against. I’ve made it a regex so that it is a little bit more flexible and can be still be used even if your organization does not use a major.minor.revision format for naming builds. The important thing is that you add a capturing group in your build name regex which is used to insert the new revision number into the build name. Note that if you don’t use svn for scm, the plugin still works and inserts the build number in place of the revision number. The other configuration is for setting the initial build name for your project like 1.00.00.

The plugin also makes available a BUILD_NAME environment variable for any scripts that might need it.

Hope this plugin helps anyone looking for nicer build names and thanks to the Jenkins project for a great build tool.

The plugin source is available on Github and you are free to fork and tinker with it suit your needs.

Tags: ,
%d bloggers like this: