# Integrate Jenkins with GitHub (using Poll SCM)

In 
Published 2022-12-03

This tutorial explains to you how to integrate Jenkins with GitHub using poll SCM option.

There are 2 ways we can integrate Jenkins with GitHub:

  • using a Poll SCM strategy : when Jenkins on a regular basis check for updates in GitHub
  • using a webhook strategy : when GitHub trigger the Jenkins job after every push in the repo

In this tutorial I prent the Poll SCM strategy method.

Prerequisites:

  • we have a GitHub repository named "GitRepo1"
  • we have created the application from the tutorial named Compile & Run a Java Application in Jenkins
  • We have Jenkins already installed
  • "HelloWorld.java" class is in the root directory of the "GitRepo1"

The steps for integrating Jenkins and GitHub using a Poll SCM strategy are:

  1. Configure the Project url - take a look at the picture below:

  2. Configure the Repository url - take a look at the picture below:

  3. Select the branch on which we are looking at for seeing new commits:

  4. Check "Poll SCM" and choose the polling interval:

  1. Define what Jenkins will do when it sees a new commit on the "GitRepo1" repository:

In my case Jenkins compile HelloWorld.java file and run the application.

Here we have the code for HelloWorld.java file:

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!"); 
    }
}

Now the configuration is completed, and we can verify if all works as expected.

This could be done by modifying something in the Java code (could be directly in GitHub) and take a look in Jenkins at "Git Polling Log".

You can verify also the Job Logs and that the HelloWorld.class file is generated on Jenkins machine.