Jenkins Beginners Tutorial

Software Development domain is well known for buzz-words. With the growth of agile movement, Continuous Delivery (CD) and Continuous Integration (CI) terms become highly popular. One of the best tool supporting the processes of CD and CI is Jenkins.

Jenkins is an continuous delivery and continuous integration server application. Typical use-cases of Jenkins are building your application from version control system, running acceptance tests or deploying application on dev/test/prod environments. Jenkins is free and cross-platform, and it’s web application written in Java, so it comes as a .war file.

In this article, we will perform basic and most common configuration of Jenkins job. Our scenario is to checkout project from git repository and run tests. Last step would be to generate test report.



Typically we would like to have Jenkins installed on remote machine. For purpose of this tutorial, we will deploy Jenkins on our local machine. First thing we need is Java JDK installed. Since there are dozens of tutorials guiding you thorough Java installation on internet, we will assume that you have it done. To check correctness of your installation, open terminal and type:

java -version

…and you should see something like this (version can be different, but I recommend 1.8 at least):

java version “1.8.0_60”
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

Tomcat configuration

Jenkins comes as .war file, so we need to deploy it somewhere. In order to do so, next thing is to download and configure Tomcat server. You can download Tomcat here (we will go with the Tomcat 8 version). After downloading it and unziping, we have to set $CATALINA_HOME environment variable, pointing to tomcat root directory. In my case, I have to add a line in my .profile:

export CATALINA_HOME=/Users/testdetective/Applications/apache-tomcat-8.0.26

Then, go to apache-tomcat-8.0.26/bin directory and run (if you are having problems running startup script due to lack of execute permissions, just run chmod ug=rwx * inside /bin directory):


If there was no errors in console output, open your browser at go to http://localhost:8080, and you should see:

Screen Shot 2015-09-24 at 12.07.10

To shutdown Tocat server, you need to run shutdown script from /bin directory:


Jenkins deployment

Download jenkins .war file from here (column on the right side of the page, under Java Web Archive (.war) section) and save it to your $CATALINA_HOME/webapps/ directory. Now you can run tomcat (or restart it, if you didn’t shut it down with script):


…and open http://localhost:8080/jenkins in your browser. You should see Jenkins up and running (jobs list can differ):

Screen Shot 2015-09-24 at 12.05.35

Job configuration

As a reminder, our task is to create a job to clone repository, run tests and publish report. We will use repository with Selenium acceptance test from my github. First of all, we have to add Git plugin. To do so:

  1. click on the Manage Jenkins on the left
  2. go to Manage plugins and change tab to Available
  3. filter list with GIT plugin
  4. mark checkbox next to GIT plugin 
  5. click Install without restart
  6. click Go back to the top page

Now lets start creating new job:

  1. click New Item on the left
  2. type the name of the job
  3. check Freestyle project
  4. click OK

Screen Shot 2015-09-24 at 13.24.13

You should be redirected to configuration page of your job. Lets create step definitions for our job:

  1. under source code management select Git
  2. under Repository URL paste following:
  3. in Build section click on the Add build step button and select: execute shell
  4. in the command text box paste following: ./gradlew clean test
  5. in Post-build Actions section click on the Add post-build step button and select: Publish JUnit test result report
  6. under Test report XMLs paste following: build/test-results/*.xml
  7. click Save

So let me explain what happened here. Basicly we’ve created new Jenkins job and configured it. In steps 1-2 we’ve choosed Git as a version control system for our repository, and point to our repository URL. In steps 3-4 we’ve defined action to run ./gradlew clean test script, that runs tests from the project (gradlew is a wrapper to download newest gradle distribution). In steps 5-6 we’ve told Jenkins to look for the xml test reports in build/test-results directory, and publish them in job’s build results view.

After configuration is done, we can run our brand new job and check test results. To run the job, click on the Build Now link on the left. You should see progress bar in the Build History section, which means that our build is in progress (firefox should open up, since it’s implementation is used in selenium project which we run):

Screen Shot 2015-09-24 at 14.56.18

When build is completed, you can click on the build number in Build History section and check result of the specific build. From here you can see console output of the job worker:

Screen Shot 2015-09-24 at 15.31.14

…or see the tests result:

Screen Shot 2015-09-24 at 15.33.05

Continue reading
If you want to continue reading and expand your knowledge in area of  Jenkins and Continuous Integration, I recommend you these books:


Jenkins can be extremely powerful tool supporting your CI and CD processes. Of course, use case introduced in this post is just an basic example, so I encourage you to dig into more advanced Jenkins possibilities. Thanks for reading and feel free to leave a comment!