Creating a Jenkins Pipeline Job.

We will create a simple demo Jenkins pipeline job that will check for changes in GitHub every minute (Implementing Continuous Integration) and build the Java code using some basic java build steps.

Here are the steps to create a demo Jenkins pipeline Job.

Step 1. Create a Pipeline project.

✔  Click on New Item.

✔  Give a name to the Job. For eg. demo pipeline.

✔  Select Pipeline from the different types of jobs.

Step 2. Configuring the Pipeline Job

✔  In the pipeline job the first two sections General and Build Triggers are almost the same. A minor difference in the General section.

✔  Leave the General section as default.

✔  Check the Poll SCM and schedule to check for any changes for every minute using the following cron expression: * * * * *

Writing the Pipeline:

✔  Under Advanced Project Options, choose a sample pipeline script or write a sample syntax like this:

pipeline {
     agent any


✔  To generate the Git clone syntax, go to the Pipeline Syntax page.

    ✔  Select git:Git from Sample Step dropdown.


✔  Fill in the necessary fields:

    ✔  Repository URL: Give the sample source code GitHub URL

    ✔  Click on the “Generate Pipeline Syntax button”, this will create a declarative pipeline syntax for GitHub.


✔  Copy the generated script and replace that with an echo line in the steps component of the pipeline code.

✔  Next, we will add two more stages to build and run the Java code.

✔  The final pipeline code will look like this:

pipeline {
agent any

    stages {
        stage('Git clone') {
            steps {
            git ''
            sh 'javac'
            sh 'java HelloWorld'

✔  Save the configuration.

Step3. Build the Job.

✔  Click on Build Now. The pipeline would look like this:


✔  Check out the Console Output.



Create a pipeline job that will send email notifications on every failed execution.