We use cookies to ensure that we give you the best experience on our website. By continuing to browse or closing this banner, you acknowledge that you have read and agree to our Privacy Policy and Terms of Service.

Coding Jag - Get The Best News Around Test, DevOps & Automation To Your Inbox, Weekly!

Subscribe Now >
X

Jenkins Tutorial

We all know that Continuous Integration & Continuous Delivery are integral parts of DevOps, as they are used for integrating multiple stages of the methodology. There are many CI/CD tools in the market, but do you know that Jenkins, the Java-based open-source CI/CD tool, tops the popularity list? And it has always been the go-to option for DevOps professionals and beginners?

Jenkins is the oldest player in the CI/CD market, and it has more than 16,000 stars and 6,500 forks on GitHub. It also has huge community support with more than 1500 plugins to help professionals ship faster through their Jenkins Pipelines.

What is Jenkins?

Jenkins is an open-source server that is written entirely in Java. It lets you execute a series of actions to achieve the continuous integration process in an automated fashion.

This CI server runs in servlet containers such as Apache Tomcat. Jenkins facilitates continuous integration and continuous delivery in software projects by automating parts related to build, test, and deployment. This makes it easy for developers to continuously work on improving the product by integrating changes to the project.

Jenkins automates the software builds in a continuous manner and lets the developers know about the errors at an early stage. A strong Jenkins community is one of the prime reasons for its popularity.

Some of the possible steps that can be performed using Jenkins are:

  • Software build using build systems such as Gradle, Maven, and more.
  • Automation testing using test frameworks such as Nose2, PyTest, Robot, Selenium, and more.
  • Execute test scripts (using Windows terminal, Linux shell, etc.
  • Achieve test results and perform post actions such as printing test reports and more.
  • Execute test scenarios against different input combinations for obtaining improved test coverage.
  • Continuous Integration (CI), where the artifacts are automatically created and tested. This aids in the identification of issues in the product at an early stage of development.

Keep reading to learn more about Jenkins, or use the chapter links to jump around this Jenkins Tutorial.

How and Why To Use Jenkins?

Before we dive into how Jenkins works, we must understand the architecture of Jenkins. These are the series of steps that outlines the interaction between different elements in Jenkins:

  • Developers do the necessary modifications in the source code and commit the changes to the repository. A new version of that file will be created in the version control system that is used to maintain the repository of source code.
  • The repository is continuously checked by Jenkins CI server for any changes (either in the form of code or libraries) and changes are pulled by the server.
  • In the next step, we ensure that the build with the ‘pulled changes’ is going through or not. The Build server performs a build with the code, and an executable is generated if the build process is successful. In case of a build failure, an automated email with a link to build logs and other build artifacts is sent to the developer.
  • In case of a successful build, the built application (or executable) is deployed to the test server. This step helps in realizing continuous testing where the newly built executable goes through a series of automated tests. Developers are alerted in case the changes have caused any breakage in functionality.
  • If there are no build, integration, and testing issues with the checked-in code, the changes, and tested application are automatically deployed to the Prod/Production server.

Here is the diagrammatic representation of the Jenkins architecture:

Ready to learn how to: install and configure Jenkins, Setup Master & Agent(s) In Jenkins, and more?

Learn More!!

Check out our blog on How & Why To Use Jenkins?

Creating Your First Jenkins Pipeline

Do you know a well-defined Jenkins pipeline can help shorten production times and improve the quality of applications? It provides a definitive structure to your existing building process, committing, automation testing, and deployment. In this chapter, we will help you create your first Jenkins pipeline and run Selenium automation in Jenkins through an online Selenium Grid.

What Is Jenkins Pipeline?

A pipeline is defined as a series of events or tasks which are interconnected in a particular order. In simple terms, the Jenkins pipeline is a set of modules or plugins which enable the implementation and integration of Continuous Delivery pipelines within Jenkins.

The Jenkins pipeline has an expandable automation system for building basic or complicated ‘template’ distribution pipelines via the Domain-specific language (DSL) used in the pipeline. There are four states of Continuous Delivery in Jenkins pipeline-

  • Build
  • Deploy
  • Test
  • Release

Learn More!!

Ready to create a Jenkins Pipeline and run your first test? Check out our Jenkins Pipeline Tutorial.

Integration Of Jenkins With Selenium WebDriver

Today all the organizations are adopting DevOps as it promises to provide best practices starting right from planning, testing to deployment, and monitoring. CI/CD tools like Jenkins play an integral role in allowing organizations to implement DevOps. Jenkins integration with Selenium makes the entire process of Selenium test automation so much easier.

Before we look into Jenkins integration with Selenium, let us quickly define what is Selenium.

What Is Selenium?

Selenium is an open source automation tool that has been widely used for testing web applications. It is easy to use, and it provides support forums, which makes it popular among the testing community. Selenium has four main components: Selenium IDE, Selenium RC, Selenium WebDriver, and Selenium Grid, designed and used for different purposes. Selenium provides cross-browser testing and parallel testing features, which allows the testers to execute their test cases in different operating systems and browsers, which ensures browser compatibility of the web application.

There are multiple ways to integrate Jenkins with Selenium WebDriver. In this chapter, we will take you through different ways to do so, which would help you implement based on your project requirements.

Integrating Maven And Jenkins With Selenium

We all know that Jenkins is a popular tool for continuous integration, build management, and automation testing. But do you know that Maven is a popular build automation tool; widely used for Java projects? The combination of Selenium, Maven, Jenkins integration is the pinnacle of continuous integration and deployment.

As a part of automation testing, we’re sure your team comes up with numerous Selenium test automation scripts every other day. As Selenium itself is not used for Continuous integration, Selenium, Maven, and Jenkins integration are leveraged for build management and continuous integration. In this chapter, we look at the usage of Maven and Jenkins with Selenium.

Before we demonstrate the usage of Selenium Maven Jenkins integration, let’s take a look at the main advantages of using Maven and Jenkins with Selenium:

Advantages Of Using Maven & Jenkins With Selenium

  • Whenever a change is made in the implementation, the changes are deployed on the test environment. Automation testing is performed continuously, and developers are kept informed about the build and test stage results.
  • Test suites that comprise many test scenarios (or test combinations) might take a longer duration for automation testing. A nightly build run can be scheduled for build and execution on the Jenkins server in such cases.
  • As Maven uses pom.xml, it reduces the overall dependency of the manual download of jar files. Also, the ‘Maven Project’ type in Jenkins helps in getting started with Selenium Maven, Jenkins integration with a few configuration settings.
  • The Selenium Maven Jenkins integration setup is suited for developing and testing teams distributed across different geographical locations.

Learn More!!

Ready to integrate Maven and Jenkins with Selenium. Check out our tutorial on >How To Integrate Jenkins & Maven With Selenium?.

Jenkins Best Practices

We all know that Jenkins is one of the most popular go-to DevOps automation tools for many software development teams. But if you want to get good results from this popular DevOps tool, you need to follow the best practices. With that in mind, we want to share some of Jenkin's best practices in this chapter.

Learn More!!

To learn these best practices check out our blog on Jenkins Best Practices.

Join 400,000+ developers & testers who rely on LambdaTest for web testing
NOW.