HOW TO ADD WEBHOOK IN GITLAB?

WHAT IS WEBHOOK?

There are many cases where an event happening in one system need to be informed to another system to trigger some related events/actions in the second system. Webhook is a web callback or HTTP push API, which will provide information and data about an event to other applications.

For example: Whenever new code gets committed (event) to a code repository (first system), you may want to setup a Webhookin the repository to run and alert the build and deployment tool (second system) to redeploy the application.

HOW TO ADD WEBHOOK IN GITLAB

Webhooks help in application integrations. Apps can subscribe to certain events in other systems and will get informed when such events happen in the subscribed system. In the above example, Build and Deployment Tool has subscribed for code commit events in the Code Repository System using Webhook.

ADDING A GITLAB WEBHOOK

Step 1: Login and select a Repository

Login to Gitlab and navigate to your code repository.WordPress repository is selected as an example below.

HOW TO ADD WEBHOOK IN GITLAB

Step 2: Open Settings

Click on the settings tab to expand it to view the Webhooksub menu

HOW TO ADD WEBHOOK IN GITLAB

Step 3: Open Webhooks screen

From the left side menu (shown above), click and selectWebhook.This will open the Webhook edit screen on the right.

HOW TO ADD WEBHOOK IN GITLAB

Step 4: Edit/Add Webhook information

Add the following information in the Add Webhook screen

  • URL: Webhook URL here>
  • Secret Token: Webhook here>
  • Trigger:
  • Click Add Webhookbutton.

HOW TO ADD WEBHOOK IN GITLAB

This will enable Gitlab to send a POST request to the URL specified based on alerts set.

Now you have successfully completed setting up a Webhook for your Gitlab repository.

Interested in reading similar articles?  Please follow us on LinkedIn.

About The Author

HOW TO ADD WEBHOOK IN GITLAB

Dr. Anil Kumar

VP Engineering, CLOUD CONTROL
Founder | Vice President | CTO | Architect | Consultant | Mentor | Advisor | Faculty

Solution Architect and IT Consultant with more than 25 years of IT Experience. Served various roles with both national and international institutions. Expertise in working with both legacy and advanced technology stacks and business domains.