Jenkins is one of the most important tools used in DevOps nowadays. Hence knowledge about Jenkins is of utmost importance if one wants to dive into DevOps. A great documentation supported by an ever growing community adds to the value of Jenkins.
What is Jenkins?
Jenkins is an open source automation server. It helps us to automate code builds, testing, deployments, thereby facilitating Continuous Integration and Continuous Delivery. Jenkins is written in Java, and it runs in servlet type containers such as Apache Tomcat. Jenkins supports a number of version control systems such as:
- Mercurial, and others
Jenkins was known as Hudson when it was initially developed in 2004. It was developed by Kohsuke Kawaguchi when he was working at Sun Microsystems.The original name Hudson was changed to Jenkins in around 2011, after a dispute with Oracle, when Oracle acquired Sun Microsystems.
An automated build can be triggered in Jenkins via the below mechanisms:
- A commit made in the version control system
- A cron scheduler
- Completion of other builds
The first option is pretty common in case of Continuous Integration.
What is Continuous Integration
We have seen CI in detail in the below article:
https://www.dotnettricks.com/learn/devops/continuous-delivery-vs-continuous-deploymentHowever, we will revisit as to what is CI. Developers work on their individual branches and merge changes/commits to the main sprint branch as many times a day. A build is created as many times after validation via automated unit test cases against the build. This process is called as Continuous Integration. As the name itself implies –
- Continuous: - Regular or uninterrupted
- Integration: - Combining from various sources
Automated Unit Test Cases play a major role in CI process, the validation against the build happens to make sure that a new change committed by the developers doesn’t break the application. A CI pipeline often makes use of the below 4 entities.
- Continuous Integration Server – Jenkins, circle ci, travis ci, Team City etc.
- SCM Tool – Git, SVN, CVS etc.
- Build Tool – Ant, Maven, Gradle etc
- Automation Testing Framework – Selenium, Appium, etc
Jenkins for Continuous Integration
Jenkins is one of the most important tools used in DevOps nowadays. Hence knowledge about Jenkins is of utmost importance if one wants to dive into DevOps. A great documentation supported by an ever growing community adds to the value of Jenkins. In this article, we would be having a look at Jenkins and how does it help in Continuous Integration.
Getting Started with Jenkins
We will install Jenkins in or machine as a local installation and see the various steps and features. The Jenkins installation has certain pre-requisites:
- JDK version 8 or 11.
- A machine with at least 512 MB RAM and appropriate amount of device space.
Below are the steps to install JDK 11 from Oracle’s site. Search for JDK 11, Google will give a bunch of links, choose a valid link and it should guide you to Oracle’s download page.
I have a Windows 64 bit machine currently; hence I have chosen the windows x64 installer. Oracle will ask you to authenticate via an Oracle account, create one if you don’t have (pretty straight-forward).
Once properly authenticated, the download will be available. Download the JDK and install it.
Download Jenkins from the below url, it would download the latest Jenkins.war file.
http://mirrors.jenkins.io/war-stable/latest/jenkins.warAlternatively for Windows a MSI installer too can be downloaded from Jenkins mirror site available at
Browse to the folder where Jenkins has been downloaded via command prompt.
Check for java –version to see whether java has been installed correctly. If there’s an error that Java is not a command, then probably you’ll need to add the JDK path to the Environment variables (It’s a very common issue).
Execute the java -jar jenkins.war --httpPort=8080. The above command executes successfully and we get a message on the command prompt that Jenkins is fully up and running.
Let us browse to
http://localhost:8080/, and we see Jenkins login screen over there.
We need to insert the initial admin password to continue further. The password can be found at
C:\Users\<username>\.jenkins\secrets\initialAdminPassword. We put in our secret admin password and click on Continue.
Jenkins provides us with an opportunity to either select our plugins or go ahead with a standardized suggested set of plugins.
To keep things simple at the moment, we’ll go with the suggested plugins option. Let’s wait for a while for all plugins to get initiated.
73 plugins are installed with the standard suggested option. The plugins are all installed and we are asked to create our first admin user, let’s enter the relevant details and proceed.
Provide the default instance for Jenkins and proceed.
Once we configure the instance, our Jenkins setup is complete.
Below is the Jenkins dashboard.
Jenkins is quite configurable, services are available as plugins and one needs to install relevant plugins for his/her work.
ROI of Jenkins
- Jenkins is free.
- It increases productivity as there isn’t any time wasted on doing continuous integration once Jenkins is setup and configured properly.
- Jenkins is highly configurable. It integrates seamlessly with other tools such as SonarQube, Selenium etc.
- Issues, build failures are detected almost instantly, which lessens the manual time taken.
- Good supportive community.
- Rich documentation.
We have tried to define Jenkins in the above article and have also seen how Jenkins promotes the Continuous Integration culture. We installed Jenkins as a local setup and explored various nuances associated with it. We will be back with advanced articles on Jenkins, create CI/CD pipelines and much more.