Jenkins in the Cloud – Enabling Continuous Integration on a PaaS

You’ve got your OpenShift on my Jenkins!  No, you’ve got your Jenkins on my OpenShift!!  Argue it how you’d like, but that’s exactly how it works and its going to help you build quality processes into your Web Applications hosted on OpenShift.  Now you can focus on the quality of your code as well, and we’ll take care of the rest.  In this blog, we’ll go through:

 – What is Jenkins?
 – How to create and access your Jenkins App
 – How to configure your application to build on Jenkins
 – Shortcuts
 – Benefits of using Jenkins on OpenShift
 – Troubleshooting

What is Jenkins?
Jenkins is an open source continuous integration server used to monitor and execute repeatable jobs like builds or cron (and much, much more).  See Jenkins for more details.

How to create and access your Jenkins App
To create a full blown Jenkins instance in OpenShift, just run:

rhc app create jenkins jenkins-1.4

This will create a specific Jenkins application for your use within your domain.  As with any application creation on OpenShift, it will clone the git repo but since Jenkins is a standalone server, we only include a README as there isn’t a need to “modify” the code.  Please review the README for more details.  As this is a full blown Jenkins instance, you can elect to install plugins from the vast library available to any Jenkins instance.  The first thing I do is install the Green Balls plugin as I’m not used to Blue markers to mean “Pass”.  While you’re at it, check out the plugins we’ve already installed.  We’ve open sourced the Jenkins Cloud Plugin:

We also print the admin password as well as a link to modify your password.  Please change your password to something you can remember as we don’t store it.

How to configure your application to build on Jenkins
Once you have Jenkins server running, you will need to configure each application to use it.  This involves configuring your app to use Jenkins, and creating your build job.  This is the hard part but we’ve simplified it.  Just run:

 rhc cartridge add -a {appUnderTest} -c jenkins-client-1.4

Review the resulting build job on Jenkins.  Feel free to modify the build job ({appUnderTest}-build) or add jobs to do what is necessary to ensure that the code meets your quality criteria before your apps changes are in production.

As if it wasn’t easy enough, we’ve added another shortcut for you.  If you don’t already have a Jenkins app running, you can create an application with Jenkins enabled in one command:

 rhc app create -a {appUnderTest} -t {appType} –enable-jenkins

This will create a default Jenkins application called “jenkins” and will create your app with the Jenkins client cartridge installed.

Benefits of using Jenkins on OpenShift
There are simply too many reasons why you would want to leverage Jenkins as a Continuous Integration server so I won’t go into those details.  In the context of OpenShift, however, the benefits are:

 – Archived Build information
 – No application downtime during the build process
 – Failed builds do not get deployed (leaving the previous working version in place)
 – More resources to build your application (in the context of Java applications, you can choose to build your applications on small or medium gears)

For more details, please review the README in the Jenkins application’s GIT repository.

To trigger a build, just do a git push.  Instead of building on your application’s gear, it will run the build job(s) configured for that trigger, and update your application when all jobs pass. 

Just like any other application, you can ssh onto to gear that runs Jenkins as well as tail the Jenkins application’s log file.  That will allow you to manage diskspace, and review any errors in the logs.  You can also log onto Jenkins (http://jenkins-{domain} to view your build logs, errors, etc. 

Some of the common issues is that after a git push to your app that is configured to build on Jenkins, the build request sits on the queue waiting for an executor.  Jenkins uses one of your gears, and the builder/executor uses another (although it is transient).  You may be out of gears.  Another common issue is that you may run out of diskspace as 1GB would hold an average of 5 builds.  In either case, please send an email to to request for more gears, or storage.  Please include your rhlogin, and your Jenkins application URL.

Jenkins, News, OpenShift Online
Comments are closed.