Github Plugin Webhooks - part 2

(this post is part of the material I cover in my devops course)

In the previuos post we have create smee.io infrastructre that can be used to deliver push notification from Github to Jenkins.
Now we can go to Github and Jenkins to configure those webhooks.

Github Plugin

Configuring Webhook in Github

  • Browse to your repository in github.com
  • Choose settings, then Webhooks
  • Click on the Add webhook button on the top-right
  • Fill the Payload URL with the smee.io url you have saved
  • Choose application/json as the content type
  • Select Send me everything
  • Click on the Add webhook button

Configuring Webhook in Jenkins pipeline

  • Go to your pipeline configuration and click on:
    GitHub hook trigger for GITScm polling
  • If you click on the question mark next to it, you'll see that this configuration belongs to the Github plugin
  • Your pipeline should use SCM to get the Jenkinsfile (credentials if needed), and the Github plugin will compare the repository identity of this repository, with the identity of the repository of the notification.
    If they match, Github plugin will initiate a build.
  • Note that you should have also configured a branch to build (even if this is a manual build) so only push to this branch (of others if you add them) will initiate builds.

Testing your webhook configuration

  • Create a change in any of the branches you have configured, then push.
  • Wait for the build