BntMrx
BntMrx

Reputation: 2367

Jenkins: GitHub hook trigger for GITScm polling

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"?

Upvotes: 25

Views: 39388

Answers (4)

fsinisi90
fsinisi90

Reputation: 1158

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

Edit: I haven't tested this but just in case: apparently if you leave the url without a trailing /, as seen in the screenshot, you may get a 302 error. Include the trailing /.

Upvotes: 18

Hồng Sơn Vũ
Hồng Sơn Vũ

Reputation: 11

All of the above are valid. But this one just to verify that the slash "/" at the end of the webhook you put on github is very important!

Upvotes: 0

Teemu
Teemu

Reputation: 121

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

Upvotes: 11

network_newbie
network_newbie

Reputation: 166

It is a source code management section (before triggering section), uncheck "none" case and check git ou github case(depend to your version) and fill the input field with your git repo url and credentialenter image description here

Upvotes: 0

Related Questions