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

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…

Testing Asynchronous APIs: Awaitility tutorial

Despite the growing popularity of test automation, most of it is still likely to be done on the frontend side of application. While GUI is a single layer that puts all the pieces together, focusing your automation efforts on the backend side requires dealing with distributed calls, concurrency, handling their diversity and integration.
Backend test automation is especially popular in the microservices architecture, with testing REST API’s. I’ve noticed that dealing with asynchronous events is particularly considered as challenging. In this article I want to cover basic usage of Awaitility – simple java library for testing asynchronous events. All the code examples are written in groovy and our REST client is Rest-Assured.
Synchronous vs Asynchronous In simple words, synchronous communication is when the API calls are dependent and their order matters, while asynchronous communication is when the API calls are independent. Quoting Apigee definition:
Synchronous  If an API call is synchrono…

Notes after TestingCup 2018

On May 28-29th I attended TestingCup conference in Łódź. Having quite unique perspective: this was my second year in row as a Speaker at this conference I want to share some thoughts on the event. Dust has settled, lets go! 

Championship Originally TestingCup is a software testing championship. Wait, what? Yes, the formula is unique: teams and individuals from all around Poland are competing in finding the most bugs and defects in specially prepared application - Mr. Buggy. I don’t have specific data, but since this year’s conference was all english I guess competitors were not only from Poland. As a spectator, I must say that the whole competition looked very professional. There were team shirts and names, podium and trophies (gold cup and cash). 
Some cons? Testing championship is held at the first day of the conference. So this is already a conference, but if you’re not taking part in the championship… there’s not much to do, since all the talks are in the next day. Organizers are aw…