Jenkins-Build when a change is pushed to GitHub option is not working

…衆ロ難τιáo~ 提交于 2019-11-27 11:40:35

I suspect you missed the webhook url.

Besides checking the Build when a change is pushed to GitHub option, you should also add the webhook url into your Github repository to get the Auto trigger mechanism to work and here is how:

Go to your Github repository:

Settings--> Webhooks&Services-->Service--> Add Services--> Choose "Jenkins (GitHub plugin)"

Then fill in the Jenkins hook url with your jenkins url like this: http://your_jenkins_url/github-webhook/


And, VERY IMPORTANT, since you are installing your jenkins server in your localhost, please be aware that you shouldn't fill in above Jenkins hook url like http://localhost:8080/github-webhook/ because Github is not able to recognize localhost or 127.0.0.1 or 192.168.*.*.

Either you should use an externally accessible DNS name or an IP address, which can be recognized by Github.

I had the same problem and solved it. The problem was that the URL had to end with a /. Meaning:

http://<jenkinsurl>:8080/github-webhook/ worked.

http://<jenkinsurl>:8080/github-webhook didn't. (Notice the missing / at the end.)

suprakash

Actually if you do the webhook settings from Jenkins -> Github plugin configuration (mentioned above), you will still see webhooks get created in github. So, above two approaches basically doing the same thing.

I personally like it to create webhook from Github, because in this way you don't have to share or store github user info in jenkins.

Steps :

  1. Login into Github (with Admin)

  2. Go to the repository you want to hook with jenkins

  3. Click on settings tab -> webhooks & services
  4. Click on Add Webhook.
  5. Enter payload url : like : http://:8080/github-webhook/
  6. Select content type as json.
  7. you are done.

Now you do the changes and commit , you will see jenkins build get trigger automatically. Don't forget to do the settings in jenkins jobs to start the build when push code in github.

The GitHub plugin (https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin) mentioned two ways: manual mode and automatic mode. mainframer gives the answer to the manual mode. Today I found something new. mainframer's add to the service doesn't allow me to add multiple Jenkins's instance, so I add the others add the Webhook as shown below. It also works fine.

I wanted to include a picture here but my id doesn't have the right to do so.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!