ghprb
ghprb copied to clipboard
ghprb not automatically setting webhooks with correct `events`
When ghprb automatically sets the webhooks, does it set the events
parameter like so?
{...
'events': ['issue_comment', 'pull_request'],
...}
I've been using the plugin for a while, but today I went to check the webhooks because they weren't triggering as expected (on comments), and I found that the events trigger was only set to push
.
I thought this worked in the past, so I don't have an explanation for this behavior.
UPDATE: This will probably help those who are manually configuring or find that they need to manually configure the webhooks.
https://github.com/blog/1778-webhooks-level-up
This is an issue for me as well. So far, I've left projects as crons.
I'm seeing this issue as well... Jenkins has been failing to trigger a build on new pull requests due to the event not matching either of issue_comment
or pull_request
:
GHPRB Log:
Jan 22, 2014 4:57:59 PM INFO org.jenkinsci.plugins.ghprb.GhprbRootAction doIndex
Got payload event: push
Jan 22, 2014 4:57:59 PM WARNING org.jenkinsci.plugins.ghprb.GhprbRootAction doIndex
Request not known
GitHub Plugin Log (NOT GHPRB)
Jan 22, 2014 4:57:59 PM INFO com.cloudbees.jenkins.GitHubWebHook processGitHubPayload
Received POST for https://github.com/trinitronx/test-repo
Jan 22, 2014 4:57:59 PM FINE com.cloudbees.jenkins.GitHubWebHook
Full details of the POST was {"ref":"refs/heads/develop","after":"db1c464ad5c06e22496fd27eaeb99243d00cb575","before":"e35209b12f2f364326b0f8aca026a02788a630ef","created":false,"deleted":false,"forced":false,"compare":"https://github.com/trinitronx/test-repo/compare/e35209b12f2f...db1c464ad5c0","commits":[{"id":... 194 Has decision engine in applet api added","timestamp":"2014-01-21T07:26:24-08:00","url":"https://github.com/trinitronx/test-repo/commit/0858a16909fb9b44c83f3017632ffca0b15810c8","auth...Cuzella","email":"[email protected]","username":"trinitronx"},"committer":{"name":"James Cuzella","email":"[email protected]","username":"trinitronx"},"added":[],"removed":[],"modified":["app/views/api/v2/shared/_applet.json.jbuilder","spec/controllers/api/v2/api_applets_controller_spec.rb"]},{"id":"992adcb9e16c782abf9d3d55153c428607f7f988","distinct":false,"message":"#Backend-194 Added more stuff to api and updated spec","timestamp":"2014-01-21T08:20:54-08:00","url":"https://github.com/trinitronx/test-repo/commit/992adcb9e16c782abf9d3d55153c428607f7f988","auth...Cuzella","email":"[email protected]","username":"trinitronx"},"committer":{"name":"James Cuzella","email":"[email protected]","username":"trinitronx"},"added":[],"removed":[],"modified":["app/views/api/v2/shared/_applet.json.jbuilder","spec/controllers/api/v2/api_applets_controller_spec.rb"]},{"id":"ca5bd8666e5c7c8c57f40b3d08d7573e306e96eb","distinct":false,"message":"#backend-194 updated spec","timestamp":"2014-01-21T09:31:56-08:00","url":"https://github.com/trinitronx/test-repo/commit/ca5bd8666e5c7c8c57f40b3d08d7573e306e96eb","auth...Cuzella","email":"[email protected]","username":"trinitronx"},"committer":{"name":"James Cuzella","email":"[email protected]","username":"trinitronx"},"added":[],"removed":[],"modified":["app/views/api/v2/shared/_applet.json.jbuilder","spec/controllers/api/v2/api_applets_controller_spec.rb"]},{"id":"6efd3c5de4ea8b5cfb3faa5b15c99ad00b4ac967","distinct":false,"message":"#backend-194 updated comments to make readable by client debs","timestamp":"2014-01-22T07:52:17-08:00","url":"https://github.com/trinitronx/test-repo/commit/6efd3c5de4ea8b5cfb3faa5b15c99ad00b4ac967","auth...Cuzella","email":"[email protected]","username":"trinitronx"},"committer":{"name":"James Cuzella","email":"[email protected]","username":"trinitronx"},"added":[],"removed":[],"modified":["app/controllers/api/v2/applets_controller.rb"]},{"id":"db1c464ad5c06e22496fd27eaeb99243d00cb575","distinct":true,"message":"Merge pull request #2699 from trinitronx/feature/bk-194/has_decision_engine_in_applet_api_endpoint\n\nFeature/bk 194/has decision engine in applet api endpoint","timestamp":"2014-01-22T08:57:57-08:00","url":"https://github.com/trinitronx/test-repo/commit/db1c464ad5c06e22496fd27eaeb99243d00cb575","auth... pull request #2699 from trinitronx/feature/bk-194/has_decision_engine_in_applet_api_endpoint\n\nFeature/bk 194/has decision engine in applet api endpoint","timestamp":"2014-01-22T08:57:57-08:00","url":"https://github.com/trinitronx/test-repo/commit/db1c464ad5c06e22496fd27eaeb99243d00cb575","auth... Portal & API","homepage":"","watchers":1,"stargazers":1,"forks":1,"fork":false,"size":115768,"owner":{"name":"trinitronx","email":null},"private":true,"open_issues":6,"has_issues":false,"has_downloads":true,"has_wiki":true,"language":"JavaScript","created_at":1321484915,"pushed_at":1390409877,"master_branch":"develop","organization":"TangoGroup"},"pusher":{"name":"trinitronx","email":"[email protected]"}}
Jan 22, 2014 4:57:59 PM FINE com.cloudbees.jenkins.GitHubWebHook
Considering to poke android-unit-tests
Jan 22, 2014 4:57:59 PM FINE com.cloudbees.jenkins.GitHubWebHook
Skipped android-unit-tests because it doesn't have a matching repository.
Jan 22, 2014 4:57:59 PM FINE com.cloudbees.jenkins.GitHubWebHook
Considering to poke program_creator_staging_jruby
Jan 22, 2014 4:57:59 PM INFO com.cloudbees.jenkins.GitHubWebHook processGitHubPayload
Poked program_creator_staging_jruby
Jan 22, 2014 4:57:59 PM FINE com.cloudbees.jenkins.GitHubWebHook
Considering to poke web_client_master_agregate
Jan 22, 2014 4:57:59 PM FINE com.cloudbees.jenkins.GitHubWebHook
Skipped web_client_master_agregate because it doesn't have a matching repository.
Jan 22, 2014 4:58:01 PM INFO com.cloudbees.jenkins.GitHubPushTrigger$1 run
SCM changes detected in program_creator_staging_jruby. Triggering #16
Looks like my last commit did not trigger the build, but the previous one did... Looking at the plugin's code, it does a check for the header: X-GitHub-Event
for "issue_comment"
or "pull_request"
If it's not either of those events, it does nothing...
public void doIndex(StaplerRequest req, StaplerResponse resp) {
String event = req.getHeader("X-GitHub-Event");
String payload = req.getParameter("payload");
if(payload == null){
logger.log(Level.SEVERE, "Request doesn't contain payload.");
return;
}
GhprbGitHub gh = GhprbTrigger.getDscp().getGitHub();
logger.log(Level.INFO, "Got payload event: {0}", event);
try{
if("issue_comment".equals(event)){
GHEventPayload.IssueComment issueComment = gh.get().parseEventPayload(new StringReader(payload), GHEventPayload.IssueComment.class);
for(GhprbRepository repo : getRepos(issueComment.getRepository())){
repo.onIssueCommentHook(issueComment);
}
}else if("pull_request".equals(event)) {
GHEventPayload.PullRequest pr = gh.get().parseEventPayload(new StringReader(payload), GHEventPayload.PullRequest.class);
for(GhprbRepository repo : getRepos(pr.getPullRequest().getRepository())){
repo.onPullRequestHook(pr);
}
}else{
logger.log(Level.WARNING, "Request not known");
}
}catch(IOException ex){
logger.log(Level.SEVERE, "Failed to parse github hook payload.", ex);
}
}
Has anyone managed to manually create a web hook using the new UI? I'm unsure what the payload version or URL should be? Also, is it expected that the "ping" test messages sent out by GitHub to test a new web hook will fail? Everything that gets sent seems to get a 302 back for me.
Thanks!
What I observed was that the webhook url was working fine, but GitHub was sending a request with a header X-GitHub-Event
. This header had the event name push
. The GHPRB plugin was looking for the strings: issue_comment
or pull_request
, which did not match the string push
... get it?
This is what I've set and am sending/receiving:
Seem to get the same results with the other payload version (form encoding) too.
@mikemcquaid Aha! Looks like GitHub has made a change to the webhooks UI since I checked last. The new features show that there are indeed multiple events which you can tell GitHub to send, and the default is to send "Just the push
event". Now I can see that the webhook Jenkins automatically set up was using a private IP to our jenkins master, and did have the issue_comment
and pull_request
events.
However since it was a private IP (and GitHub could obviously not contact this one), I had set up another webhook using a public IP for our Jenkins server. However, there was no way to select which events the webhook would send using the old GitHub webhooks page. It seems that this has now changed and they have updated the page to even show the last payloads that GitHub has sent! This is great and would have made debugging this much easier.
The one that I had set up manually was apparently only sending the push
event... which makes sense because that's what I was seeing on the other end :wink:
So in conclusion:
- New GitHub Web UI rocks!
- Jenkins GHPRB plugin must have been setting up the webhook correctly via the API to send correct events, but with private IP
- Manually setting up a webhook with the old GitHub Web UI resulted in the default setting: "Just the
push
event"
@mikemcquaid To fix your problem, you might want to double check that your URL is publically accessible and that you're using the correct port for your jenkins master.
The default that the GHPRB plugin setup for me was using port 8080
: http://jenkins.example.com:8080/ghprbhook/
It looks like your IP resolves ok for me, port 80 works and 8080 is firewalled. Double check your firewall settings too :wink:
Just now I was being curious about when the GitHub web UI changed & I noticed an anomaly: smlstvnh originally commented on this on 2013-10-21 14:00:53
(presumably with the "Webhooks Level Up" link unless the comment was edited?), I commented on 2014-01-29 16:24:47
and at that point in time, the new UI was not available for me to change the hook events. The date on the GitHub blog page about the update ( Webhooks Level Up ) says February 11, 2014
.
So either the original comment was edited, or the blog post was, or the date on the blog post is wrong, GitHub was doing A/B testing & I couldn't see the page, or some combination of those possibilities. Either way.. I'm just happy the new Webhooks UI is the way it is now.
@trinitronx good eye! You're right, I updated the issue description. I should have put it in an EDIT block.
I think we can call this fixed on GitHub's end... maybe this should be documented though?
I'm having a hard time using hooks to trigger builds as well. I've setup everything just as @trinitronx image shows but I am getting only 302 requests back from jenkins.
Twist is, I have jenkins locked down w/matrix based security so Anonymous users can't do anything. I've included the token
var w/my jenkins access token in the ghprb hook but no dice.
Are any of you guys forcing login in your jenkins?
@BrandonMathis I am and am also having issues. Perhaps that's why.
Yeh, I think this is my issue too. It looks like we need something like this for GHPRB. Ideally it would just use the /github-webhook
instead:
@mikemcquaid Please try adding a trailing slash to the web hook url (see #133).
@dirk-thomas unfortunately I had already but thanks for the tip.
Hey all, I'm having the same issue but I'm running an older version of Github Enterprise without the new UI.
I manually put in http://myserver:8080/ghprbhook/
as a Webhook URL and also under the Jenkins Plugin service hook on github. When I "Test hook" the Webhook URL, I get:
Mar 31, 2014 4:48:43 PM org.jenkinsci.plugins.ghprb.GhprbRootAction doIndex
INFO: Got payload event: push
Mar 31, 2014 4:48:43 PM org.jenkinsci.plugins.ghprb.GhprbRootAction doIndex
WARNING: Request not known
When I "Test Hook" the Jenkins plugin URL, I get:
Mar 31, 2014 4:48:53 PM org.jenkinsci.plugins.ghprb.GhprbRootAction doIndex
INFO: Got payload event: null
Mar 31, 2014 4:48:53 PM org.jenkinsci.plugins.ghprb.GhprbRootAction doIndex
WARNING: Request not known
That is "okay" since the plugin will only handle issue_comment
and pull_request
events. All others (like push
and null
) will be ignored.
You should make sure to only check those two events for the webhook.
@smlstvnh I'll check it out, thanks.
Just wanted to add, that if there is both a ghprbhook and an SCM on-push enabled (Github plugin), then the github plugin will work.
If there is only SCM on-push trigger, you will need to change the Github URL to /github-webhook