Creating Webhook and SCM Polling in Jenkins

Creating Webhook and SCM Polling in Jenkins

Create webhook for the app in github

By creating webhook in github app repository and connecting it with jenkins, make sures whenever you make any changes in the code in github, it automatically triggers and starts building the pipeline.

  1. Go to app repository in github and click on settings

  2. Select Webhooks > click on Add Webhook

  3. Now enter the jenkins URL in the below format and check the appropriate event and click on Update webhook making sure you have kept a check on Active

     http://<Jenkins URL>:8080/github-webhook/
    

  4. Now check whether the connection is established with a ✅ sign

  5. Now go to Jenkins, select create a Job by selecting pipeline, enter the github repository where the code is saved and also check on GitHub hook trigger for GITScm polling.

Create SCM polling

SCM polling by default is present in jenkin which is use to detect jenkinsfile present with code in github repository. So no need to write any groovy script in jenkins.

  1. Create a job. Enter the project name and select pipeline.

  2. In the configuration of the job after entering github repository and trigger type scroll down to Pipeline, click on drop box and select Pipeline script from SCM.

  3. Enter the github repository URL where jenkinsfile is present. It will automatically search for jenkinsfile in the github in master branch

  4. The name can be different as well not necessarily Jenkinsfile. You may keep a different name where pipeline script is written. Below in the Script Path, it is Jenkinsfile which it'll be searching in github repository which is provided.

  5. After saving the configuration Build the job and it will start building the pipeline script which is written in Jenkinsfile.