nemccarthy / stash-pullrequest-builder-plugin

A Jenkins plugin for Building Stash Pull Requests
https://wiki.jenkins-ci.org/display/JENKINS/Stash+pullrequest+builder+plugin
Other
64 stars 130 forks source link

Poll fails with NullPointerException #48

Closed aWildElephant closed 8 years ago

aWildElephant commented 8 years ago

Hello,

I've tried to set up a job using the Stash pullrequest builder plugin but it fails to poll Stash with a NullPointerException:

Oct 13, 2015 5:02:01 PM WARNING hudson.triggers.Trigger checkTriggers stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run() failed for hudson.maven.MavenModuleSet@2aa7eb8[my-job-name] java.lang.NullPointerException at stashpullrequestbuilder.stashpullrequestbuilder.StashRepository.postBuildStartCommentTo(StashRepository.java:72) at stashpullrequestbuilder.stashpullrequestbuilder.StashRepository.addFutureBuildTasks(StashRepository.java:77) at stashpullrequestbuilder.stashpullrequestbuilder.StashPullRequestsBuilder.run(StashPullRequestsBuilder.java:31) at stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run(StashBuildTrigger.java:168) at hudson.triggers.Trigger.checkTriggers(Trigger.java:282) at hudson.triggers.Trigger$Cron.doRun(Trigger.java:221) at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:51) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

I'm guessing that the method postPullRequestComment encountered an UnsupportedEncodingException or an IOException and returned null. I don't understand the benefit of this behavior however, since the upstream error message is lost and no check is done to see if the method suceeded or not.

I was hoping you could clarify that for me. The plugin works perfectly with a similar configuration on my 'test server', which is a virtual machine running jenkins and stash. I feel like I won't be able to move forward without a meaningful error message.

I'm working with Jenkins v1.627 and the version 1.3.1 of the plugin.

Best regards.

nemccarthy commented 8 years ago

added a fix for this one. try 1.4.1 release

aWildElephant commented 8 years ago

Thanks for your quick response, I didn't want to restart Jenkins right away but I'll test this as soon as I can. I managed to track down my issue to the fact the url I provided returns a 302 found. I'd say the HTTP agent you use either tries again with a GET method or does not handle it at all. I'll see if I'm able to provide a fix.

nemccarthy commented 8 years ago

If you're getting a 302 you're probably pointing to a http URL when your stash instance is running on https. You shouldn't use http for basic auth which is what we use for the stash rest api.

aWildElephant commented 8 years ago

Yes that was it. Thanks for the help!