KostyaSha / github-integration-plugin

Jenkins GitHub Integration Plugin
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Integration+Plugin
MIT License
97 stars 84 forks source link

Pull Request review Triggering #178

Open vermasumeet1982 opened 7 years ago

vermasumeet1982 commented 7 years ago

Hello I have been trying to get the build trigger when I comment on pull request to work. Attached are the job configurations. I know I am getting the webhooks from github because I can see that in Jenkins logs and also the github push event is working.

Also pasted below is jenkins log around an exception thrown when pull request review comment event is received. I have tried everything to make this work but not sure what the problem is. I think there is a bug in the plugin

screen shot 2016-12-09 at 17 33 58 screen shot 2016-12-09 at 17 34 17
Bad configured project qa_pipeline_step1 - Can't get remote GH repo for qa_pipeline_step1
java.lang.IllegalStateException: Can't get remote GH repo for qa_pipeline_step1
    at com.google.common.base.Preconditions.checkState(Preconditions.java:172)
    at com.github.kostyasha.github.integration.generic.GitHubTrigger.getRemoteRepository(GitHubTrigger.java:156)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory.forProject(GitHubPRRepositoryFactory.java:63)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory.createFor(GitHubPRRepositoryFactory.java:36)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory.createFor(GitHubPRRepositoryFactory.java:27)
    at hudson.model.Actionable.createFor(Actionable.java:107)
    at hudson.model.Actionable.getAllActions(Actionable.java:98)
    at hudson.model.Actionable.getAction(Actionable.java:165)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger.doRun(GitHubPRTrigger.java:216)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger.run(GitHubPRTrigger.java:173)
    at hudson.triggers.Trigger.checkTriggers(Trigger.java:278)
    at hudson.triggers.Trigger$Cron.doRun(Trigger.java:226)
    at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:50)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Dec 09, 2016 5:25:01 PM WARNING org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger doRun
Can't get repository info, maybe project qa_pipeline_step1 misconfigured?
Dec 09, 2016 5:27:01 PM SEVERE org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory createFor
Bad configured project qa_pipeline_step1 - Can't get remote GH repo for qa_pipeline_step1
java.lang.IllegalStateException: Can't get remote GH repo for qa_pipeline_step1
    at com.google.common.base.Preconditions.checkState(Preconditions.java:172)
    at com.github.kostyasha.github.integration.generic.GitHubTrigger.getRemoteRepository(GitHubTrigger.java:156)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory.forProject(GitHubPRRepositoryFactory.java:63)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory.createFor(GitHubPRRepositoryFactory.java:36)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRRepositoryFactory.createFor(GitHubPRRepositoryFactory.java:27)
    at hudson.model.Actionable.createFor(Actionable.java:107)
    at hudson.model.Actionable.getAllActions(Actionable.java:98)
    at hudson.model.Actionable.getAction(Actionable.java:165)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger.doRun(GitHubPRTrigger.java:216)
    at org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger.run(GitHubPRTrigger.java:173)
    at hudson.triggers.Trigger.checkTriggers(Trigger.java:278)
    at hudson.triggers.Trigger$Cron.doRun(Trigger.java:226)
    at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:50)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
KostyaSha commented 7 years ago

Did you set github project job property?

vermasumeet1982 commented 7 years ago

Thanks for prompt reply. Can you point out where do I set it?

KostyaSha commented 7 years ago

https://github.com/KostyaSha/github-integration-plugin/blob/master/docs/Configuration.adoc

vermasumeet1982 commented 7 years ago

Yes that is done with the Git repository name and I know it works if I trigger the job manually. The display name field is empty

KostyaSha commented 7 years ago

Display name unrelated. And did you set global user that has access to your repo?

vermasumeet1982 commented 7 years ago

yes. if i trigger the job manually it works. So I know the credentials are working

KostyaSha commented 7 years ago

git credentials unrelated, Trigger has repoprovider that searches for gh connection. It uses global settings....

vermasumeet1982 commented 7 years ago

ok let me check

KostyaSha commented 7 years ago

You need login under user and check that it has no pending invintations.

vermasumeet1982 commented 7 years ago

the credentials I am using to access the repo is under Jenkins (global) domain and it has no pending invitations

KostyaSha commented 7 years ago

Ah, it fails create repository for job... Is it new job or existed?

vermasumeet1982 commented 7 years ago

new

KostyaSha commented 7 years ago

Maybe connection was bad and cached #175 ... will do release now

vermasumeet1982 commented 7 years ago

cool. let me know when done, I will upgrade the plugin and run it again

vermasumeet1982 commented 7 years ago

when will the update be available via Jenkins Plugin Manager?

KostyaSha commented 7 years ago

release in process, if you install Jucies update center it should appear very fast: my release, checkbox on github, build on jitpack and available in jucies. In main jenkins update center it appears only tomorrow.

vermasumeet1982 commented 7 years ago

0.1.0-rc17 installed. That exception is gone but trigger still not occuring

vermasumeet1982 commented 7 years ago

should i check or uncheck cache connection in github plugin repository provider?

KostyaSha commented 7 years ago

Cache makes sense only if it found wrong connection. How much users do you have in global settings? Did you restart your jenkins? Do you have anything in global jenkins log?

vermasumeet1982 commented 7 years ago

yes I did restart. I did get this after some time at the end of the event

Stopping 'Build GitHub Pull Requests' for project 'qa_pipeline_step1'
Dec 09, 2016 6:58:32 PM INFO org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger start
Starting GitHub Pull Request trigger for project qa_pipeline_step1

So something happened but job didn't trigger. I have removed the refspec for testing and specified a fix branch in branch specifier just for test purpose

vermasumeet1982 commented 7 years ago

is the refspec and branch to build in above screenshots correct?

KostyaSha commented 7 years ago

You can even not specify git at all. Trigger self containing. What is written in "polling log" when you manually press run trigger from "github PRs" page?

vermasumeet1982 commented 7 years ago

sorry was this "You can even not specify git at all." a question? I don't understand what u mean by manually press trigger from"github PR" page? Do you mean writing a comment on the PR?

Should I email you the log to your gmail address? And by log I mean the Jenkins System Log. Nothing is appearing in the github hook log on the job page

vermasumeet1982 commented 7 years ago

ok I need to go now. Its very late on friday evening. I will check pick this up again on Monday. Have a good weekend and thanks for your help

KostyaSha commented 7 years ago

Thanks, will reply with screenshots, busy atm

vermasumeet1982 commented 7 years ago

thanks

KostyaSha commented 7 years ago

github-project-property Must be specified

KostyaSha commented 7 years ago

And global settings should be set as described in github-plugin screenshot 2016-12-11 21 10 49

vermasumeet1982 commented 7 years ago

hello @KostyaSha both these settings are specified correctly (is checking manage hooks mandatory? I am not managing webhooks from jenkins). I know jenkins is receiving webhooks because I can see the packets in the jenkins log. Can you also screenshot the refspec. I want to confirm I have specified the branch and refspec correctly.

KostyaSha commented 7 years ago

disable SCM, it not needed for triggering.

KostyaSha commented 7 years ago

What job type do you use?

vermasumeet1982 commented 7 years ago

This is my build trigger. It is a freestyle project

screen shot 2016-12-12 at 10 26 44
vermasumeet1982 commented 7 years ago

I think problem is somewhere around refspec and branch. Could you screenshot those so I can compare with my settings. screen shot 2016-12-12 at 10 30 57

KostyaSha commented 7 years ago

Set only github project property and only PR trigger, don't set anything else. Don't set "when pushed to github". Ensure that you have right global settings with right user. I run fresh jenkins and setup everything the same - it works fine.

vermasumeet1982 commented 7 years ago

hey I found the reason

screen shot 2016-12-12 at 13 44 42

There are 2 tabs where u can comment in github. If you comment in "Conversations" tab Github sends issue_comment event. Header X-GitHub-Event -> issue_comment

If you comment in "Files Changed" tab, Github sends pull review comment event.

Header X-GitHub-Event -> pull_request_review
Dec 12, 2016 1:53:12 PM FINE org.jenkinsci.plugins.github.webhook.GHEventHeader$PayloadHandler parse
Unknown event - No enum constant org.kohsuke.github.GHEvent.PULL_REQUEST_REVIEW
Dec 12, 2016 1:53:12 PM FINE org.jenkinsci.plugins.github.webhook.GHEventHeader$PayloadHandler parse
Header X-GitHub-Event -> pull_request_review_comment

I think your plugin looks for issue_comment event and not the Pull Request comment. I think it would be better if you update the plugin to handle pull request review comment or mention this in the documentation.

Many thanks for your support. I will close this after some more checking

KostyaSha commented 7 years ago

M.... It should be pretty simple to make new event that will check PR review comments. Local storage saves anything needed for next check point, but i not sure that all this comments are very linear like conversation. If you want implement it i can guide you. For more than year you are the first who tried to trigger build via review comment :)

vermasumeet1982 commented 7 years ago

We have our gitflow setup like that. I wanted to deliver a release to QA team before PR is merged. And that's how I came across this plugin. For now please document this in your Configuration.doc file. I will contact you if I want to upgrade this plugin.

Although I should have figured it out earlier as your plugin logging does say Unknown event - No enum constant org.kohsuke.github.GHEvent.PULL_REQUEST_REVIEW

I was just looking at the wrong place :)

KostyaSha commented 7 years ago

You can keep issue open.