Create CI Pipeline Job in Jenkins

Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.

In this tutorial, we will be building the following stages of our CI pipeline:

Follow the below steps to create the above pipeline job in Jenkins:

1. Clone this sample GitHub repository in your local (https://github.com/patebija/HelloWorldExample.git).

2. Go to Jenkins Dashboard and click on New Item.

3. Enter any item name “Demo Application”.

4. Select Maven project and click on OK button.

5. In General section, enter some text in the Description “A simple Java Application”.

6. In Pipeline section, select Definition as “Pipeline script”.

7. Copy the below Groovy script which includes all the different steps for Build, Test and Deploy.

pipeline {
   agent any

   stages {
      stage('Build') {
         steps {
            git 'https://github.com/patebija/HelloWorldExample.git'
            
            bat 'mvn -B clean package'
         }
      }
      stage('Test'){
          steps{
              bat 'mvn test'
          }
          post{
              always{
                  junit 'target/surefire-reports/*.xml'
              }
          }
      }
      stage('Report'){
          steps{
              archiveArtifacts 'target/*.jar'
          }
      }
   }
}

8. Paste the groovy script in Script section.

9. Click on Save to create your new pipeline job.

10. Go back to Jenkins Dashboard and click on “Schedule a build for Demo Application”.

11. Click on the Project to see the Stage view.

Share

Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!