Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins not triggered by github-webhook

I have taken these steps:

  • Check "GitHub project" and set up the project
  • Check "GitHub hook trigger for GITScm polling"
  • Setup connection to private repository with user/password
  • If I build manually, it works
  • In GitHub, create a webhook on push to http://my_jenkins_url/github-webhook/
  • Whenever I commit something, it shows that a webhook has been sent and I get a 200 response code (on github)

But no build is triggered on Jenkins. The GitHub Hook Log says: "Polling has not run yet.". How can I make it "start"? How can I further debug this?

EDIT: I have not added a GitHub Server in Manage Jenkins -> Configure -> GitHub since I ran into issue with the authentication (but that would be a different question). Is this required for github webhooks?

EDIT2: I figured out how to add a GitHub API to the Jenkins config (using Personal Access Token with git hook access enabled). But it doesn't seem to make a difference.

like image 671
Jodo Avatar asked Jun 22 '19 09:06

Jodo


1 Answers

I found how to fix it properly.

First. set Jenkins logger at Jenkins manage > system log

add log recoder, with this configuration

hudson.plugins.git.GitStatus - All
com.cloudbees.jenkins.GitHubWebHook - All
org.jenkinsci.plugins.github - All

Second. Hook trigger again.

and check logger again. In my case, the logger says

Skipped {ProjectName} because it doesn't have a matching repository.

Third. Check the webhook url where the webhook request exactly came from.

it will be specified at logger like this:

Received PushEvent for https://github.com/{username}/{reponame} from {ip} ⇒ http://{your jenkins url}/github-webhook/

Fourth. Again go to jenkins project configuration,

check whole github urls are exactly same as https://github.com/{username}/{reponame} at step 3.

No .git at last.

I hope this answer helps you. Thank you

like image 126
blue-hope Avatar answered Oct 29 '22 00:10

blue-hope