Technotes

Technotes for future me

Jenkins create git webhook

Create and enable a GitHub repository webhook

Create a GitHub repository and configure it such that GitHub automatically notifies Jenkins about new commits to the repository via a webhook.

  • Log in to GitHub and create a new repository. Note the HTTPS URL to the repository.
  • Click the “Settings” tab at the top of the repository page.
  • Select the “Webhooks” sub-menu item. Click “Add webhook”.
  • In the “Payload URL” field, enter the URL http://IP-ADDRESS/jenkins/github-webhook/, replacing the IP-ADDRESS placeholder with the IP address if your Jenkins deployment.
  • Ensure that “Just the push event” radio button is checked and save the webhook.

Create a Jenkins pipeline project

At this point, you are ready to start setting up your Jenkins pipeline. Follow the steps below to create a new project.

  • Log in to Jenkins (if you’re not already logged in).
  • Click “New item”. Enter a name for the new project and set the project type to “Pipeline”. Click “OK” to proceed.
  • Select the “General” tab on the project configuration page and check the “GitHub project” checkbox. Enter the complete URL to your GitHub project.
  • Select the “Build triggers” tab on the project configuration page and check the “GitHub hook trigger for GITScm polling” checkbox.
  • Select the “Pipeline” tab on the project configuration page and set the “Definition” field to “Pipeline script from SCM”.
    Set the “SCM” field to “Git” and enter the GitHub repository URL. Set the branch specifier to “*/master”.
    This configuration tells Jenkins to look for a pipeline script named Jenkinsfile in the code repository itself.
  • Save the changes.
Last updated on 31 Jan 2021
Published on 19 Dec 2019
Edit on GitHub