CICD Pipeline in Jenkins (original) (raw)

Last Updated : 30 Apr, 2026

A CI/CD pipeline in Jenkins automates the process of building, testing, and deploying code. It helps developers integrate changes and deploy them quickly and reliably. Jenkins makes this automation easy and efficient.

Create CI-CD Pipeline in Jenkins

Step 1: **Log In to Jenkins

Log in to your Jenkins account. This is where all your Jenkins jobs and pipelines will be configured and monitored.

Jenkins login

Login Window Jenkins

Step 2: **Redirected to the Jenkins Dashboard

When you logged in, you will be redirected to the Jenkins console or dashboard. This is where you can manage all your Jenkins jobs, pipelines, and settings.

Step 3: **Create a New Project

On the Jenkins dashboard, click on the "New Item" option to create a new project select the option available in the Dashboard.

New Item

Step 4: Configure the Project Type

On the next screen, list of options will be visible, along with a field to name the pipeline. Add a suitable name and select the "Pipeline" option to proceed.

item name & Type

Step 5: **Configure the General Section

The pipeline configuration page will open. In the General section:

Step 6: **Set Build Triggers

In the Build Triggers section:

We need to specify the branch and repository and give the credentials too. And add additional behaviors if required so far. Refer to the screenshot to have a better understanding.

Step 7: Advanced Project Options

In the Advanced Project Options section:

Step 8: **Configure the Pipeline Section

This is the most critical part of the configuration process. In the Pipeline section:

Pipeline script

Sample Jenkins Pipeline Script

groovy `

node { // Define the Maven tool used for the build process def mavenHome = tool name: 'Maven 3.8.6'

// Configure build properties (e.g., log rotation and SCM polling)
properties([
    buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '5', daysToKeepStr: '', numToKeepStr: '5')),
    pipelineTriggers([pollSCM('* * * * *')])
])

// Checkout code from the Git repository
stage('Checkout Code') {
    git branch: 'development', credentialsId: 'github-credentials-id', url: 'https://github.com/your-username/your-repository.git'
}

// Build the project using Maven
stage('Build') {
    sh "${mavenHome}/bin/mvn clean package"
}

// Execute code quality analysis with SonarQube
stage('Execute SonarQube Analysis') {
    sh "${mavenHome}/bin/mvn clean sonar:sonar"
}

// Upload the build artifact to Nexus repository
stage('Upload Build Artifact') {
    sh "${mavenHome}/bin/mvn clean deploy"
}

// Deploy the application to Tomcat using SCP
stage('Deploy to Tomcat') {
    sshagent(['your-ssh-credentials-id']) {
        sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war ec2-user@your-server:/opt/apache-tomcat-9.0.64/webapps/"
    }
}

}

`

Step 9: Save the Pipeline and Run It

After writing the pipeline is done click on save it will be directly redirected to the Dashboard of the project there we can use, the "Build Now" option to run the pipeline and check if it is successful or not, by using stage view or console output.

Build Now

Step 10: Monitor the Pipeline Execution

Once the pipeline is triggered, you can monitor its progress:

**Stage View: Provides a visual representation of the pipeline stages and their status (success, failure, etc.).

Stage view

**Console Output: Displays the detailed logs of each stage. This is useful for debugging any issues that may occur during the pipeline execution.

Step 11: **Review the Build Status

At the bottom of the Console Output or Stage View, you will see the status of the pipeline:

Console Output logs

Output of the pipeline

Here we successfully created a Jenkins CI/CD pipeline to automate the process of building, testing, and deploying a Java web application .war file.