Jenkins Tutorial

Jenkins Tutorial

Last updated on 19th Sep 2020, Blog, Tutorials

About author

Damodharan (Team Lead DevOps Engineer )

He is A TOP Rated Domain Expert with 7+ Years Of Experience Also, He is a Technology Writer for Past 2 Years to Imparts Informative Blog for Fresher's & JOB Seeker

(5.0) | 16223 Ratings 989

What is Jenkins?

Jenkins is an open source automation tool written in Java programming language that allows continuous integration.

Jenkins builds and tests our software projects which continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build.

It also allows us to continuously deliver our software by integrating with a large number of testing and deployment technologies.

Jenkins offers a straightforward way to set up a continuous integration or continuous delivery environment for almost any combination of languages and source code repositories using pipelines, as well as automating other routine development tasks.

With the help of Jenkins, organizations can speed up the software development process through automation. Jenkins adds development life-cycle processes of all kinds, including build, document, test, package, stage, deploy static analysis and much more.

Jenkins achieves CI (Continuous Integration) with the help of plugins. Plugins is used to allow the integration of various DevOps stages. If you want to integrate a particular tool, you have to install the plugins for that tool. For example: Maven 2 Project, Git, HTML Publisher, Amazon EC2, etc.

For example: If any organization is developing a project, then Jenkins will continuously test your project builds and show you the errors in early stages of your development.

Possible steps executed by Jenkins are for example:

  • Perform a software build using a build system like Gradle or Maven Apache
  • Execute a shell script
  • Archive a build result
  • Running software tests

Work Flow:

developers-check-their-source-code

What is Continuous Integration?

Continuous Integration (CI) is a development practice in which the developers are needs to commit changes to the source code in a shared repository at regular intervals. Every commit made in the repository is then built. This allows the development teams to detect the problems early.

Continuous integration requires the developers to have regular builds. The general practice is that whenever a code commit occurs, a build should be triggered.

Subscribe For Free Demo

Error: Contact form not found.

Continuous Integration with Jenkins

Let’s consider a scenario where the complete source code of the application was built and then deployed on a test server for testing. It sounds like a perfect way to develop software, but this process has many problems.

  • Developer teams have to wait till the complete software is developed for the test results.
  • There is a high prospect that the test results might show multiple bugs. It was tough for developers to locate those bugs because they have to check the entire source code of the application.
  • It slows the software delivery process.
  • Continuous feedback pertaining to things like architectural or coding issues, build failures, test status and file release uploads was missing due to which the quality of software can go down.
  • The whole process was manual which increases the threat of frequent failure.

It is obvious from the above stated problems that not only the software delivery process became slow but the quality of software also went down. This leads to customer dissatisfaction.

So to overcome such problem there was a need for a system to exist where developers can continuously trigger a build and test for every change made in the source code.

This is what Continuous Integration (CI) is all about. Jenkins is the most mature Continuous Integration tool available so let us see how Continuous Integration with Jenkins overcame the above shortcomings.

Let’s see how Jenkins works. The above diagram is representing the following functions:

  • First of all, a developer commits the code to the source code repository. Meanwhile, the Jenkins checks the repository at regular intervals for changes.
  • Soon after a commit occurs, the Jenkins server finds the changes that have occurred in the source code repository. Jenkins will draw those changes and will start preparing a new build.
  • If the build fails, then the concerned team will be notified.
  • If build is successful, then Jenkins server deploys the built in the test server.
  • After testing, Jenkins server generates a feedback and then notifies the developers about the build and test results.
  • It will continue to verify the source code repository for changes made in the source code and the whole process keeps on repeating.

Advantages and Disadvantages of using Jenkins

Advantages of Jenkins

  • It is an open source tool.It is free of cost.
  • It does not require additional installations or components. Means it is easy to install.
  • Easily configurable.
  • It supports 1000 or more plugins to ease your work. If a plugin does not exist, you can write the script for it and share with community.
  • It is built in java and hence it is portable.
  • It is platform independent. It is available for all platforms and different operating systems. Like OS X, Windows or Linux.
  • Easy support, since it is open source and widely used.
  • Jenkins also supports cloud based architecture so that we can deploy Jenkins in cloud based platforms.

Disadvantages of Jenkins

  • Its interface is out dated and not user friendly compared to current user interface trends.
  • Not easy to maintain because it runs on a server and requires some skills as server administrator to monitor its activity.
  • CI regularly breaks due to some small setting changes. CI will be paused and therefore requires some developer’s team attention.

Jenkins Architecture

Jenkins follows Master-Slave architecture to manage distributed builds. In this architecture, slave and master communicate through TCP/IP protocol.

Jenkins architecture has two components:

  • Jenkins Master/Server
  • Jenkins Slave/Node/Build Server
master-slave-architecture

Jenkins Master

The main server of Jenkins is the Jenkins Master. It is a web dashboard which is nothing but powered from a war file. By default it runs on 8080 port. With the help of Dashboard, we can configure the jobs/projects but the build takes place in Nodes/Slave. By default one node (slave) is configured and running in Jenkins server. We can add more nodes using IP address, user name and password using the ssh, jnlp or webstart methods.

The server’s job or master’s job is to handle:

  • Scheduling build jobs.
  • Dispatching builds to the nodes/slaves for the actual execution.
  • Monitor the nodes/slaves (possibly taking them online and offline as required).
  • Recording and presenting the build results.
  • A Master/Server instance of Jenkins can also execute build jobs directly.

Jenkins Slave

Jenkins slave is used to execute the build jobs dispatched by the master. We can configure a project to always run on a particular slave machine, or particular type of slave machine, or simple let the Jenkins to pick the next available slave/node.

As we know Jenkins is developed using Java is platform independent thus Jenkins Master/Servers and Slave/nodes can be configured in any servers including Linux, Windows, and Mac.

jenkins-master-will-distribute

The above diagram is self explanatory. It consists of a Jenkins Master which is managing three Jenkins Slaves.

Using Jenkins 

This chapter contains topics for typical Jenkins users (of all skill levels) about Jenkins usage which is outside the scope of the core Jenkins features: Pipeline and Blue Ocean.

If you want to create and configure a Pipeline project through a Jenkinsfile or through Blue Ocean, or you wish to find out more about these core Jenkins features, refer to the relevant topics within the respective Pipeline and Blue Ocean chapters.

If you are a Jenkins administrator and want to know more about managing Jenkins nodes and instances, see Managing Jenkins.

If you are a system administrator and want learn how to back-up, restore, maintain as Jenkins servers and nodes, see Jenkins System Administration.

Glossary

Agent

An agent is typically a machine, or container, which connects to a Jenkins master and executes tasks when directed by the master.

Artifact

An immutable file generated during a Build or Pipeline run which is archived onto the Jenkins Master for later retrieval by users.

Build

Result of a single execution of a Project

Master

The central, coordinating process which stores configuration, loads plugins, and renders the various user interfaces for Jenkins.

jenkins Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

Node

A machine which is part of the Jenkins environment and capable of executing Pipelines or Projects. Both the Master and Agents are considered to be Nodes.

Project

A user-configured description of work which Jenkins should perform, such as building a piece of software, etc.

Pipeline

A user-defined model of a continuous delivery pipeline, for more read the Pipeline chapter in this handbook.

Jenkins Certification Course:

Jenkins is an open-source automation server that allows developers to build, test, and deploy their software. It is popular for the management of source code and delivering code to production. With Jenkins, organizations can manage and control the software delivery processes throughout the entire lifecycle, including build, document, test, package, stage, deployment, static code analysis, and much more.

Discuss Jenkins

Jenkins is a powerful application that allows continuous integration and continuous delivery of projects, regardless of the platform you are working on. It is a free source that can handle any kind of build or continuous integration. You can integrate Jenkins with a number of testing and deployment technologies. In this tutorial, we would explain how you can use Jenkins to build and test your software projects continuously.

Conclusion

As we come to the end of this Jenkins tutorial, we can now recall all the major concepts related to Jenkins such as ‘What is Jenkins?’ and its role in the CI/CD space, how to set up Jenkins and create masters and slaves, the huge world of plugins that are available in Jenkins, and much more. It is suggested to try out installing newer plugins and also uploading them to the community to keep them alive.

Further in this Jenkins tutorial, we have learned how to create builds and how to schedule them as per our needs. The creation of CI/CD pipelines is one of the most important aspects of Jenkins that we have taken a look at. Now, we need to be creating our own jobs and scheduling them with different parameters to get a more in-depth working knowledge of it.

Jenkins is one of the most valuable DevOps Tools out there at our disposal. Learning the ways and skills with Jenkins can be an invaluable asset. To learn more and get certified, head over to Intellipaat to find the best trainers and e-learning courses. Get DevOps certified today!!

Are you looking training with Right Jobs?

Contact Us

Popular Courses