Jenkins is a opens source continuous integration server.
This blog post will show you how
- to set up Jenkins in an Ubuntu 11.04 Virtual Box
- create a simple Git controlled Project with Jenkins
- run the build job
We are going to put Jenkins into a virtual Ubuntu 11.04 (Natty) Box. Therefore we use vagrant with our self made base box
1 2 3 4 5
We need to customize the Vagrantfile a little bit for our needs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Since we configured a
postinstall.sh script provisioner, we need to create it
1 2 3 4 5 6
And finally start the virtual box:
1 2 3 4 5
Check if our provisioner run:
Next we are going to install Jenkins into our Ubuntu box. Therefore we are
going to add the following lines into the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
This Script runs now every time on:
or, if the box is already running:
Recap – What happened so far
- We created a new Ubuntu 11.04 (Natty) Server Box with Vagrant
- We created a Vagrant Shell Provisioner
- We installed Jenkins from the provided Ubuntu Package Repository
- Jenkins will be launched as a daemon
- Logs will be located in
- The config is in
- Jenkins listens on port 8080
If everything went good so far, we should be able to open up our favorite browser and go to http://localhost:8080.
Congratulations, Jenkins is at your command!
If something went wrong, check the
postinstall.log and login to the virtual
Setting up your first Project
Our first project will be on GitHub, thus, we need to install the Git Plugin first.
Go to the Jenkins Plugin Manager
and select the
Git Plugin and the
Click on “Download now and Install after restart”. On the Installation Site, click the checkbox to restart Jenkins after Installation.
Now we are ready to start our first Project.
Click on New Job and select Build a free-style software project. Set the Job Name to MyJob
Set the following Values on the Job configuration Site
- Projectname: MyJob
- Description: A simple test Job
- GitHub Project: https://github.com/ramonski/jenkins-server
- Git Repository Url: https://github.com/ramonski/jenkins-server.git
- Important Check “Skip internal tag” Option, since we make anonymous checkouts
- Build trigger: Build when a change is pushed to GitHub and activate the
checkbox to check the source code management system periodically. Add ther a
* * * * *which basically means to check every minute.
- Select “Shell Script” for build
The Build Script
You can customize how to build your Project. Therefore you can use Environment Variables
For testing, we echo the values of the build number and the build id into a file:
Ok, lets start our first build! Click on build now
The Build should be successful.
You should be able to view the buildinfo inside your workspace.
If your build failed, check the build log
If you get the following error:
you probably set the Read+Write Repository URL in the Project Config. Log out from GitHub and take then the (Read Only) Repository URL.
Another error could tell you this:
then you probably forgot to set the “Skip internal tag” on the Job configuration Site
Now it’s time to prepare Jenkins for the real world. You probably don’t want that everyone can maintain Jenkins through the Web. So you need to create some Users and give them the propert rights, or you can configure Jenkins to talk to your companies LDAP.
If you plan to hook the Vagrant Box into your local Network, you can enable Bridged Networking in your Vagrant Config.
There are also a lot of other cool Plugins available for Jenkins, so check out your the Plugin Manager.
A collection of some plugins we use:
Jenkins IRC Plugin This plugin is an IRC bot that can publish build results to IRC channels.
ChuckNorris Plugin Displays a picture of Chuck Norris (instead of Jenkins the butler) and a random Chuck Norris ‘The Programmer’ fact on each build page.
Python Plugin Adds the ability to execute python scripts as build steps.
Jython Plugin Adds the ability to execute Jython script as a build step in free-style software projects from within the JVM.
- updated Vagrant File for Vagrant 0.9