Post

Setting up Webhook on localhost using ngrock (Jenkins)

Automate build on code commit

1. Ngrock Setup

  • Download ngrok for Mac OS
  • unzip and connect your account using terminal commands
  • Start the service using ./ngrok http 8080
  • Copy the Forwarding URL

Screenshot-2021-01-27-at-2.06.40-PM-1024x752

2. Jenkins Configuration

It listens for requests at the hook URL. We need to give this URL to the GitHub repository. Jenkins will run the build process whenever code is pushed to the repository.

  • Open Dashboard
  • Go to Manage Jenkins > Configure System.
  • Under GitHub select the ‘Advanced‘ tab.
  • Check ‘Specify another hook URL for GitHub configuration‘ and paste the Forwarding URL copied from the terminal.
  • Go to item configuration and underbuild trigger tab, check ‘GitHub hook trigger for GITScm polling‘

Screenshot-2021-01-27-at-2.16.57-PM-1024x644

Screenshot-2021-01-27-at-2.38.33-PM-1024x711

3. GitHub Repository Configuration

  • Open Github Repository
  • Click ‘Settings‘
  • Click ‘Webhooks‘
  • Click ‘Add webhook‘
  • Paste the Forwarding URL in ‘Payload URL‘
  • Only push events will be triggered with this webhook
  • Click ‘Add webhook‘

Screenshot-2021-01-27-at-2.18.00-PM-1024x789

Now try to commit and if everything goes well it will build automatically.

Screenshot-2021-01-27-at-2.25.28-PM-1024x696

This post is licensed under CC BY 4.0 by the author.