Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: GitHub hook trigger for GITScm polling

Tags:

jenkins

I try to configure Jenkins. I want a simple behavior: trigger a build on new pull request.

So, I created a job and configured it, but I checked the checkbox for: enter image description here

And as you can see nothing is dropped down.

If I click the question mark on the right side, I see:

If jenkins will receive PUSH GitHub hook from repo defined in Git SCM section it will trigger Git SCM polling logic. So polling logic in fact belongs to Git SCM.

But where is the "Git SCM section"?

like image 349
Benoit Mariaux Avatar asked Jan 04 '18 10:01

Benoit Mariaux


People also ask

What is GitHub Hook trigger for GITScm polling in Jenkins?

The Github Integration plugin will add the “Github hook trigger for GITScm polling” option for you. Which means that every time Jenkins receives a PUSH GitHub hook (from the repository you defined in the Source Code Management section) it will trigger the polling login you previously defined.

How do I add a GitHub hook to GITScm polling?

Click the GitHub hook trigger for GITScm polling checkbox on the build job. Create and copy a Jenkins API token for the Jenkins user who will run the build job. Create a trigger in your GitHub repository's settings page. Set the GitHub payload URL to be your Jenkins' IP address with /github-webhook/ appended to it.


2 Answers

You need to configure the webhook on your GitHub repository. Then, on every commit push, Jenkins will be notified.

So, open your repository in the browser, then go to Settings > Webhooks and add a new one.

enter image description here

Then, enter the URL of your Jenkins instance followed by /github-webhook and select the other options depending on your needs:

enter image description here

like image 142
fsinisi90 Avatar answered Oct 12 '22 07:10

fsinisi90


I was also frustrated with this topic, this was needed for me to get job triggering working from GitHub MERGE:

  • GitHub repo -> Settings -> Webhooks -> push type webhook with URL: http(s)://host:<port>/github-webhook/

    For me, last slash was REQUIRED, did not work without it

  • In Jenkins System Settings, add GitHub Server, credential for it and [x] Manage hooks

  • Use Test settings button to test it works

  • In Job configuration, Source Code Management -> Git, add repo and credentials

  • Under Build triggers: [x] GitHub hook trigger for GITScm polling

  • In GitHub webhook settings, click webhook and it shows logs how it worked under "Recent Deliveries" title

like image 6
Teemu Avatar answered Oct 12 '22 07:10

Teemu