Understanding the basics of the Jenkins

Understanding the basics of the Jenkins

This will be a series of tutorials on Jenkins, and we'll start at the very beginning and work our way up. We will first go over What Jenkins Is and How to Use It. Later on, we'll talk about Jenkins jobs, plugins for Jenkins, and other related topics. Later, we'll go over using Jenkins for continuous integration.

Lets Start!

What is Jenkins and Why do we use it?

Jenkins is an open-source automation server that is used to automate various tasks, such as building, testing, and deploying software. The primary purpose of Jenkins is to provide a simple way to manage and control the process of building, testing, and deploying software, enabling developers to focus on writing code rather than worrying about the underlying infrastructure.

Jenkins is often used in software development to automate the non-human part of the software development process. This can include building, testing, and deploying software. Jenkins can be used to automate tasks such as building, testing, and deploying software, as well as other tasks such as managing and maintaining the underlying infrastructure. This allows developers to focus on writing code, rather than worrying about the underlying infrastructure.

In short, Jenkins is a tool that helps automate various parts of the software development process, making it easier for developers to build, test, and deploy their software.

Workflow of Jenkins

jenkins ci cd.png

  • We can attach git, Maven, selenium and antifactory plugins to jenkins.

  • Once developers put code in github, jenkins pull that code and send to maven for build.

  • Once build is done, jenkins pull that code and sends to selenium for testing.

  • Once testing is done, then jenkins will pull that code and send to artifactory as per requirement and so on.

  • We can also deploy with jenkin

Jenkins Pipeline

Jenkins Pipeline is a suite of plugins that allows Jenkins to support continuous delivery (CD) pipelines. With Jenkins Pipeline, the pipeline definition is stored in a Jenkinsfile, which is typically checked into source control along with the other source files for the application. This allows the pipeline definition to be versioned and managed along with the rest of the application.

about jenkins.png

Jenkins Pipeline provides a number of features that enable Jenkins to support CD pipelines, including:

  • The ability to define the pipeline in a Jenkinsfile, which is a text file that contains the definition of the pipeline, including the steps and stages involved in the workflow, as well as the necessary inputs and outputs.

  • The ability to run the pipeline on any Jenkins agent, including agents that are managed by Jenkins, as well as agents that are running on-premises or in the cloud.

  • The ability to easily visualize the pipeline and its status, including the ability to view the pipeline as a graphical diagram.

  • The ability to monitor the pipeline and its individual steps, including the ability to view the pipeline console output and the pipeline artifacts (e.g. JUnit test results, code coverage reports).

Overall, Jenkins Pipeline is a powerful tool that helps automate and manage the process of building, testing, and deploying software, enabling developers to focus on writing code rather than worrying about the underlying infrastructure.

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'echo "Builing..."'
                //other related code for building
            }
        }
        stage('Test') {
            steps {
                sh 'echo "Testing..."'
                //other related code for testing 
            }
        }
        stage('Deploy') {
            steps {
                sh 'echo "Deploying..."'
                //other related code for building 
            }
        }
    }
}

Understanding the pipeline

  • Jenkins pipeline: A Jenkins pipeline is a suite of plugins that allows Jenkins to support continuous delivery (CD) pipelines. The Jenkins pipeline is defined in a Jenkinsfile, which is typically checked into source control along with the other source files for the application.

  • Jenkins agent: A Jenkins agent is a server or node that is used to run the individual steps in a Jenkins pipeline. Jenkins agents can be managed by Jenkins, or they can be on-premises or cloud-based servers.

  • Jenkins node: In the context of Jenkins, a node is a term used to refer to a Jenkins agent or slave. A node is a server or machine that is used to run the individual steps in a Jenkins pipeline.

  • Jenkins stages: A Jenkins stage is a named, logical group of steps in a Jenkinsfile. Stages are used to organize and group the individual steps in a Jenkins pipeline, making it easier to understand and manage the pipeline.

  • Jenkins steps: A Jenkins step is an individual task that is performed in a Jenkins pipeline. Steps are the building blocks of a Jenkins pipeline and are used to perform the individual tasks that are necessary to build, test, and deploy an application.

Overall, these are the main terms and concepts that are used in the context of Jenkins pipelines.

There are several reasons why you should use the Jenkins pipeline:

  1. It allows you to define the entire continuous delivery (CD) pipeline in a Jenkinsfile, which is typically checked into source control along with the other source files for the application. This allows the pipeline definition to be versioned and managed along with the rest of the application.

  2. It provides a number of features that make it easy to manage and automate the CD pipeline, including the ability to run the pipeline on any Jenkins agent, visualize the pipeline and its status, and monitor the pipeline and its individual steps.

  3. It enables you to easily integrate with other tools and systems, such as source code management systems, build tools, and deployment tools, allowing you to create a seamless end-to-end workflow.

  4. It allows you to define the pipeline as code, which makes it easy to maintain and modify the pipeline as needed.

Overall, the Jenkins pipeline is a valuable tool for automating and managing the continuous delivery process, enabling developers to focus on writing code rather than worrying about the underlying infrastructure.