Skip to main content

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:

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):

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

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):

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:

…or see the tests result:

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!

Popular posts from this blog

Test Automation: Good, Bad and Ugly

The modern approach to software quality and software development life cycle requires that business guys, developers and testers understand that the long manual test phase, although often still necessary, must be reduced to a minimum and replaced by test automation. Working in continuous delivery and continuous integration environment requires us to create automated tests that run on demand, checking our application integration and it’s core functionality correctness. However, there are still many problems with designing and writing automated tests, resulting in their costly maintenance or abandonment in favour of a return to manual processes.
In this article I will focus on describing common good practices of test automation. This post is more than an overview than complete reference guide. Broader aspects, such as the Page Object pattern or Page Factory will be described in detail in a separate article on this blog. Although most practices apply for every types of automated tests, thi…

REST-Assured framework overview

In modern software development, REST services becomes most popular choice for implementing distributed and scalable web application. They are light and easy to maintain, which results in faster and more effective implementation and system integration.
I recommend you also my other posts about REST-Assured and building microservice’s test automation frameworks: REST-Assured: going deeperBuilding microservices testing framework
With the increase popularity of RESTful services, there is a need for fast and lightweight tool for REST webservices testing automation. One of the most popular choice is Rest-Assured framework from Jayway. It introduces simplicity of testing web services from dynamic languages like groovy or ruby to java. In this post we will get our hands dirty and write automatic test in Rest-Assured framework.
In order to create complete implementation of automated tests in Rest-Assured framework, we need to write our code against some example API. We’ll use standalone Wiremock m…

REST-Assured: going deeper

In my previous post I described the basic REST-Assured usage – the lightweight framework for testing RESTful services. Despite the fact that described range of functionalities would be enough in most cases,REST-Assured has a lot more to offer. In this post I would like to bring some more advanced examples of the framework usage.

I recommend you also my other posts about REST-Assured and building microservice’s test automation frameworks:

REST-Assured – framework overviewBuilding microservices testing framework
Object Mapping Sending request’s body as string is easy and straightforward, but it can be inconvenient in the case of more complex operations on request / response properties. Proven solution for this is a good-known serialization of request/response body to objects. REST-Assured supports object mapping to (and from) JSON and XML. For JSON you need either to have Jackson or Gson in your classpath and for XML you need JAXB. Here is an example of request object serialization using J…