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

NullPointer since 1.3.0 #22

Closed rawler closed 8 years ago

rawler commented 9 years ago

I've upgraded to 1.3.0, and, I believe, configured according to instructions.

However, I'm faced with:

WARNING: stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run() failed for hudson.model.FreeStyleProject@2de62290[rmq_develop] java.lang.NullPointerException

Is there any way to get a stacktrace, or some sort of clue exactly what is missing?

(Stash v3.1.1)

nemccarthy commented 9 years ago

Uh oh. You might need to increase the log level. Debug level logs should work. You can turn this on at https://your-jenkins-server.com/log/. create a new log recorder called stashpullrequestbuilder.stashpullrequestbuilder set logger to the same string and set the level to all. This should give you the URL request and the response body in the logs...

If you could post back the stack trace that would be super helpful!

nemccarthy commented 9 years ago

Looks like PR #21 added a few bugs. @laurentverbruggen these changes won't work with ssh git urls.

For now roll back to 1.2

nemccarthy commented 9 years ago

I've backed out v1.3.0

rawler commented 9 years ago

After some fiddling, i suddenly saw it working. I have an (unconfirmed) idea what may have been the problem. I may have accidentally checked "Build only 'Merge before build' target branch?", without having the corresponding Git-behavior configured.

Just FYI.

rawler commented 9 years ago

Hmm, strange. "Build only 'Merge before build' target branch?" seems to check itself. Uncheck, apply & reload, and it's still checked. On a related note, I see in the build-log that the version actually built, is not the /from-version I would expect, but rather the commit automerged in stash;

Checking out Revision 2751c7f65ba193d030492a5ea1642989dd85e5d7 (origin/pr/1/merge)

However, the version reported back, (using ${pullRequestCommit}), is the /from-commit.

laurentverbruggen commented 9 years ago

If you enabled the 'Merge before build' extension it is normal that the merged revision is checked out. Without the extension it should be the origin/pr/1/from commit. The version reported back should be the from commit even if you merge before build, because stash doesn't know the merge commit and won't show the pull request as built.

laurentverbruggen commented 9 years ago

@nemccarthy it is possible that it doesn't work for ssh git urls. I haven't tested that setup because our stash isn't setup for ssh and therefor I can't test it.

rawler commented 9 years ago

OK. Any idea how I uncheck the "Build only 'Merge before build' target branch"-option?

("Merge before build" is not enabled in GitSCM)

laurentverbruggen commented 9 years ago

No, it doesn't work here as well (I need that option so I hadn't noticed it before). That indeed seems an issue that needs fixing. I'll try and fix it later. @nemccarthy will you look at the ssh issue? Do I open a new pull request?

nemccarthy commented 9 years ago

@rawler appreciate the info @laurentverbruggen please open a new PR when you're ready

Thanks!

njones11 commented 9 years ago

Just wanted to say that we're also seeing this issue. I tried to setup this plugin for the first time yesterday, and I'm getting the null pointer error using ssh:// urls. If there is anything I can do to help fix this, let me know.

laurentverbruggen commented 9 years ago

@nemccarthy can you tell me how you have set it up to test ssh? because when testing it I get an exception saying: java.lang.IllegalStateException: unsupported protocol: 'ssh' Which is not exactly a NullPointerException and suggests that ssh didn't work before my changes either...

laurentverbruggen commented 9 years ago

I've created a new pull request that should solve the NullPointerException (however, can't be sure because I couldn't reproduce the issue): #26

nemccarthy commented 9 years ago

@njones11 @laurentverbruggen I've been a way on holidays. Ill try to find time to look into this in the next week

kwin commented 9 years ago

I do have a stacktrace for that:

WARNING: stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run() failed for hudson.maven.MavenModuleSet@27a09d0e[myjob]
java.lang.IllegalArgumentException: host parameter is null
    at org.apache.commons.httpclient.HttpConnection.<init>(HttpConnection.java:206)
    at org.apache.commons.httpclient.HttpConnection.<init>(HttpConnection.java:155)
    at org.apache.commons.httpclient.SimpleHttpConnectionManager.getConnectionWithTimeout(SimpleHttpConnectionManager.java:175)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:153)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
    at stashpullrequestbuilder.stashpullrequestbuilder.stash.StashApiClient.getRequest(StashApiClient.java:140)
    at stashpullrequestbuilder.stashpullrequestbuilder.stash.StashApiClient.getPullRequests(StashApiClient.java:44)
    at stashpullrequestbuilder.stashpullrequestbuilder.StashRepository.getTargetPullRequests(StashRepository.java:57)
    at stashpullrequestbuilder.stashpullrequestbuilder.StashPullRequestsBuilder.run(StashPullRequestsBuilder.java:30)
    at stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run(StashBuildTrigger.java:168)
    at hudson.triggers.Trigger.checkTriggers(Trigger.java:266)
    at hudson.triggers.Trigger$Cron.doRun(Trigger.java:214)
    at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:54)
    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)

The git URL looks like: ssh://git@<stash-url>:7999/<project>/<repo-name>.git I left the host in the configuration empty.

Also it is not clear to me how the Stash HTTPs URL can be figured out by just looking at the SSH URL, because in our case Stash is reachable via https://source.int.netcentric.biz/stash while the git-url looks like ssh://git@source.int.netcentric.biz:7999/.... so the ssh url does not know anything about the context path stash under which stash is running!

MartinMReed commented 9 years ago

Here is another example of a NPE that we just ran into (in case it helps someone here):

Jul 21, 2015 3:19:00 PM WARNING hudson.triggers.Trigger checkTriggers
stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run() failed for hudson.model.FreeStyleProject@3c471b93[my_jenkins_build_plan_name]
java.lang.NullPointerException
    at stashpullrequestbuilder.stashpullrequestbuilder.StashRepository.getTargetPullRequests(StashRepository.java:59)
    at stashpullrequestbuilder.stashpullrequestbuilder.StashPullRequestsBuilder.run(StashPullRequestsBuilder.java:30)
    at stashpullrequestbuilder.stashpullrequestbuilder.StashBuildTrigger.run(StashBuildTrigger.java:168)
    at hudson.triggers.Trigger.checkTriggers(Trigger.java:266)
    at hudson.triggers.Trigger$Cron.doRun(Trigger.java:215)
    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:745)

I found this above it:

Failure authenticating with BASIC 'Atlassian Stash'@my.stash.host.com:8990

Tested with cURL:

$ curl --user username:********* http://my.stash.host.com:8990/rest/api/1.0/projects/MYPROJ/repos/my-repo-name/pull-requests/
{"errors":[{"context":null,"message":"CAPTCHA required. Your Stash account has been marked as requiring a CAPTCHA to be solved before you may login again. This is typically caused by too many attempts to login with an incorrect password.\nIf you are currently logged in to Stash via a browser you may need to logout and then log back in in order to clear the CAPTCHA.\n\nVisit Stash at http://my.stash.host.com:8990 for more details.","exceptionName":null}]}

Logging out and back in to handle the CAPTCHA on that account fixed it.

Plugin version 1.3.1.

TD-4242 commented 8 years ago

I seem to be getting Failure authenticating with BASIC 'Atlassian Stash'@stash:80

My user is actually 'jenkins' not 'Atlassian Stash' I'm not sure what that's getting picked up.

nemccarthy commented 8 years ago

These should be fixed. Look out for the 1.4 release