Build Trigger and webhooks in Jenkins

#90DaysOfDevOps

#Day26

What is a trigger?

A trigger bascially helps us to execute a job after the occurrence of a particular event.

To see the list of build triggers just login to Jenkins and click on any item already created and click on configure.

Trigger build remotely

URL is used to build triggers remotely.

Build after other projects are built

As it reads, mention the list of all the other projects which should be built before the present job is executed

Build periodically

The build is triggered based on the mentioned time. A cron has to be mentioned here. Here event if there are no new commits then also the build will get triggered after a given interval once the previous code is built.

Poll SCM

SCM stands for Source Code Management. "Poll SCM" polls the SCM periodically for checking if any changes/ new commits were made, in case of new commits the build is triggered.

Github hook trigger for GITSCM polling

Once any of the subscribed events occurs on GitHub, the Webhook sends a HTTP POST payload to the Webhook's configured URL and the build is triggered.

Automating Integration using Webhooks

  • Select any created project .

  • Go to Configure

  • Select GitHub hook trigger for GITScm polling from Build Triggers section and Click on Save

  • Now go to your mention repository, Click on Setting

  • From the Code and automation on the side bar select Webhooks

  • Click on add webhooks

  • In the Payload URL , enter the Url of your Jenkins with a prefix /github-webhook/ and select the event after which you want to trigger the webhooks.

    Here we will be using push event , so every time a new commit occurs the build action will be triggered.

  • Now make any changes and commit you will see your project is automatically built.

Thank you for reading!!

~Sujata Kumari