mohamicorp / stash-jenkins-postreceive-webhook

Webhook used to notify Jenkins when commits are made to Stash
Other
138 stars 98 forks source link

NPE at hook #49

Closed tgruenert closed 10 years ago

tgruenert commented 10 years ago

We get code via Subversion Mirror into stash. But the hook to jenkins never get fired. Manually Testing works fine.

Logfile: 2014-01-22 00:34:47,776 ERROR [AtlassianEvent::pool-2-thread-6] c.a.s.i.e.AsyncBatchingInvokersTransformer There was an exception thrown trying to dispatch event 'com.atlassian.stash.event.RepositoryPushEvent[source=org.tmatesoft.subgit.stash.web.SgRepositoryManager@41219615]' for the invoker 'SingleParameterMethodListenerInvoker{method=public void com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(com.atlassian.stash.event.RepositoryRefsChangedEvent), listener=com.nerdwin15.stash.webhook.RepositoryChangeListener@13e1c6a6}'. java.lang.RuntimeException: java.lang.NullPointerException at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:50) ~[atlassian-event-2.3.1.jar:na] at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:100) ~[stash-platform-2.10.0.jar:na] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2$1.run(AsynchronousAbleEventDispatcher.java:52) [atlassian-event-2.3.1.jar:na] at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:38) [sal-core-2.10.9.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51] at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51] ... 1 frame trimmed Caused by: java.lang.NullPointerException: null at com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(RepositoryChangeListener.java:47) ~[na:na] at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) ~[atlassian-event-2.3.1.jar:na] ... 6 common frames omitted

May anyone can help me or fix it if it is an bug.

Thank you, Thomas

mikesir87 commented 10 years ago

Interesting. Haven't seen that one yet. Couple of quick question...

1) Are you running the latest version of the plugin? 2) When does this occur? When your svn repo is being synced? during initial import? Any additional information would be helpful so I can recreate it and figure it out.

Thanks!

tgruenert commented 10 years ago

Dear Michaael,

1) plugin info:

Version: 2.2.1 Developer: Nerdwin15 http://www.nerdwin15.com/ Add-on key: com.nerdwin15.stash-stash-webhook-jenkins

2) this occures on svn repo sync. i altered the svn trunk which is syned to stash:

2014-01-22 23:07:46,493 INFO [schedulerWorker-2] o.t.s.stash.web.SgRepositorySync Polling SVN repository: https://**.de/evermind/projekte/raddatz/kunden-raddatz-qms 2014-01-22 23:07:46,595 INFO [schedulerWorker-3] o.t.s.stash.web.SgRepositorySync Polling SVN repository: https://**.de/evermind/projekte/raddatz/kunden-raddatz-qms-ppp 2014-01-22 23:07:48,223 INFO [schedulerWorker-3] o.t.s.stash.web.SgRepositorySync No changes were fetched from SVN repository: https://**.de/evermind/projekte/raddatz/kunden-raddatz-qms-ppp 2014-01-22 23:07:48,441 INFO [schedulerWorker-2] o.t.s.stash.web.SgRepositorySync New changes were fetched from SVN repository: https://**.de/evermind/projekte/raddatz/kunden-raddatz-qms 2014-01-22 23:07:48,442 DEBUG [AtlassianEvent::pool-2-thread-6] c.a.s.i.r.sync.ForkRefSyncListener QM/kmu-qms-webapp[3]: Not synchronizing 1 change(s); there is no associated user 2014-01-22 23:07:48,445 DEBUG [AtlassianEvent::pool-2-thread-5] c.a.s.i.p.r.PullRequestRescopeListener Skipping rescopes for repository QM/kmu-qms-webapp because the triggering user could not be determined 2014-01-22 23:07:48,445 DEBUG [Indexer:thread-1] c.a.s.i.i.ChangesetIndexingServiceImpl [QM/kmu-qms-webapp[3]] Request for indexing received 2014-01-22 23:07:48,446 DEBUG [Indexer:thread-1] c.a.s.i.i.ChangesetIndexingServiceImpl [QM/kmu-qms-webapp[3]] Starting indexing with indexers [com.atlassian.stash.JiraKeyIndexer, com.atlassian.stash.JiraKeyIndexer] 2014-01-22 23:07:48,449 ERROR [AtlassianEvent::pool-2-thread-5] c.a.s.i.e.AsyncBatchingInvokersTransformer There was an exception thrown trying to dispatch event 'com.atlassian.stash.event.RepositoryPushEvent[source=org.tmatesoft.subgit.stash.web.SgRepositoryManager@41219615]' for the invoker 'SingleParameterMethodListenerInvoker{method=public void com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(com.atlassian.stash.event.RepositoryRefsChangedEvent), listener=com.nerdwin15.stash.webhook.RepositoryChangeListener@13e1c6a6}'. java.lang.RuntimeException: java.lang.NullPointerException at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:50) ~[atlassian-event-2.3.1.jar:na] at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:100) ~[stash-platform-2.10.0.jar:na] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2$1.run(AsynchronousAbleEventDispatcher.java:52) [atlassian-event-2.3.1.jar:na] at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:38) [sal-core-2.10.9.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51] at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51] ... 1 frame trimmed Caused by: java.lang.NullPointerException: null at com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(RepositoryChangeListener.java:47) ~[na:na] at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) ~[atlassian-event-2.3.1.jar:na] ... 6 common frames omitted 2014-01-22 23:07:48,451 DEBUG [Indexer:thread-1] com.atlassian.stash.scm.BaseCommand Executed /usr/bin/git for-each-ref --format=%(refname)|%(objectname)|%(*objectname) refs/heads/ refs/tags/ 2014-01-22 23:07:48,457 DEBUG [Indexer:thread-1] c.a.s.i.jira.idx.JiraKeyIndexer Indexed 19b4a732de16570dae39fd222e62260850661df0 (Matching JIRA keys: []) 2014-01-22 23:07:48,555 DEBUG [Indexer:thread-1] com.atlassian.stash.scm.BaseCommand Executed /usr/bin/git rev-list --format=%H%x02%h%x02%P%x02%p%x02%aN%x02%aE%x02%at%n%B%n%x03 --ignore-missing --stdin -- 2014-01-22 23:07:48,555 DEBUG [Indexer:thread-1] c.a.s.i.i.ChangesetIndexingServiceImpl [QM/kmu-qms-webapp[3]] Scanning for deleted changesets... 2014-01-22 23:07:48,659 DEBUG [Indexer:thread-1] com.atlassian.stash.scm.BaseCommand Executed /usr/bin/git rev-list --format=%H%x02%h%x02%P%x02%p%x02%aN%x02%aE%x02%at%n%B%n%x03 --ignore-missing --stdin -- 2014-01-22 23:07:48,685 DEBUG [Indexer:thread-1] c.a.s.i.i.ChangesetIndexingServiceImpl [QM/kmu-qms-webapp[3]] Indexed 1 changesets

Hope this helps.

Thomas

Am 22.01.2014 12:36, schrieb Michael Irwin:

Interesting. Haven't seen that one yet. Couple of quick question...

1) Are you running the latest version of the plugin? 2) When does this occur? When your svn repo is being synced? during initial import? Any additional information would be helpful so I can recreate it and figure it out.

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/Nerdwin15/stash-jenkins-postreceive-webhook/issues/49#issuecomment-33014105.

Thomas Grünert

evermind GmbH Schorlemmerstraße 1 04155 Leipzig

Tel.: +49 (0)341-25 39 66 - 0 Fax: +49 (0)341-25 39 66 - 1

Web: http://www.evermind.de E-Mail: thomas.gruenert@evermind.de

HRB: 21586 Amtsgericht Leipzig

Geschäftsführer: Christoph Klemm

vs commented 10 years ago

Hi,

I'm SubGit & SVN Mirror for Stash developer, I think this information might be interesting for you:

When the plugin fetches new revisions from Subversion repository, it raises RepositoryPushEvent with the following ref change:

0000000000000000000 0000000000000000000 refs/heads/artificialRefForSVNSyncEvent

This allows us to trigger repository re-indexing as you can see that in the debug logs provided.

Hope that gives you any hint, Semyon

mikesir87 commented 10 years ago

Hi @vs! It looks like the NPE is being thrown because there is no user set for the event. Does that sound consistent with how the plugin works?

I guess I could simply check for a null user, but had assumed that a user should be provided when events are triggered.

vs commented 10 years ago

Hi @mikesir87, indeed, we pass null as an argument there because we have no user information at that moment.

I doubt it's possible to use any reasonable user account for those events as the plugin fetches revisions from Subversion server once in a while and these revisions may belong to different authors (even to those who are not yet registered in Stash).

I had a look into Stash docs, and getUser method is annotated as Nullable, so null check is required anyway.

On a related note, RepositoryPushEvent docs has the following statement:

Listeners that are interested in all ref changes, not just those stemming from pushes (such as pull request merges), should listen for RepositoryRefsChangedEvents instead.

I think SubGit plugin should raise some relevant subclass of RepositoryRefsChangedEvent instead of RepositoryPushEvent as it makes more sense. But whatever event it is, we still can't provide any user information with it.

mikesir87 commented 10 years ago

Sounds great. I figured that was the case. Must have missed the Nullalbe when adding that in.

Thanks for your input. At least it's simple to fix. :)

mikesir87 commented 10 years ago

Problem fixed and updated plugin has been submitted to the Atlassian Marketplace. Thanks for your assistance, input, and patience!

tgruenert commented 10 years ago

Dear mikesir87 and vs, thank you for your really fast operation. As beeing a rookie at stash i hope this solution privides me a hook to trigger Jenkins builds. As i understand, the autor who triggers a build by committing to svn will get lost and this information can´t be displayed at Jenkins. This solution would be good enought for me.

Thank you a lot. Thomas

vs commented 10 years ago

@mikesir87 that was fast, thanks!

vs commented 10 years ago

@tgruenert,

As i understand, the autor who triggers a build by committing to svn will get lost and this information can´t be displayed at Jenkins. This solution would be good enought for me.

Yes, the author gets lost for commits fetched from Subversion server. I've created an issue in our tracker to collect ideas when it's possible to get author information for such commits: SG-81.

tgruenert commented 10 years ago

todays morning i updated stash webhook plugin to 2.2.2 and test my chain via svn commit as described above.

unfortunately i get a new exception. the commit does not show in stash. may you have a hint for me? or should i better ask vs?

stash webhook Setting are: ssh an Skip SSL Certificate Validation is enabled. Trigger Jenkins says "Success!"

2014-01-28 08:52:18,602 ERROR [pool-15-thread-1] root 531x503x0 9pwfz0 178.25.57.214,127.0.0.1 "POST /rest/plugins/self-update/1.0/ HTTP/1.1" o.t.s.stash.web.admin.SgUpgradeJob writing logs to : /usr/local/stash/stash-home/data/repositories/3/subgit 2014-01-28 08:52:18,645 ERROR [AtlassianEvent::pool-2-thread-2] root 531x503x0 9pwfz0 178.25.57.214,127.0.0.1 "POST /rest/plugins/self-update/1.0/ HTTP/1.1" c.a.s.i.e.AsyncBatchingInvokersTransformer There was an exception thrown trying to dispatch event 'com.atlassian.stash.event.RepositoryPushEvent[source=org.tmatesoft.subgit.stash.web.SgRepositoryManager@73b21aa2]' for the invoker 'SingleParameterMethodListenerInvoker{method=public void com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(com.atlassian.stash.event.RepositoryRefsChangedEvent), listener=com.nerdwin15.stash.webhook.RepositoryChangeListener@18b3db17}'. java.lang.RuntimeException: internal error: SHA-1 not available. at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:54) ~[atlassian-event-2.3.1.jar:na] at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:100) ~[stash-platform-2.10.0.jar:na] at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2$1.run(AsynchronousAbleEventDispatcher.java:52) [atlassian-event-2.3.1.jar:na] at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:38) [sal-core-2.10.9.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51] at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51] ... 1 frame trimmed Caused by: java.lang.InternalError: internal error: SHA-1 not available. at sun.security.provider.SecureRandom.init(SecureRandom.java:99) ~[na:1.7.0_51] at sun.security.provider.SecureRandom.(SecureRandom.java:78) ~[na:1.7.0_51] at java.security.SecureRandom.getDefaultPRNG(SecureRandom.java:191) ~[na:1.7.0_51] at java.security.SecureRandom.(SecureRandom.java:155) ~[na:1.7.0_51] at com.nerdwin15.stash.webhook.service.ConcreteHttpClientFactory.createContext(ConcreteHttpClientFactory.java:76) ~[na:na] at com.nerdwin15.stash.webhook.service.ConcreteHttpClientFactory.configuredClient(ConcreteHttpClientFactory.java:61) ~[na:na] at com.nerdwin15.stash.webhook.service.ConcreteHttpClientFactory.createHttpClient(ConcreteHttpClientFactory.java:51) ~[na:na] at com.nerdwin15.stash.webhook.service.ConcreteHttpClientFactory.getHttpClient(ConcreteHttpClientFactory.java:38) ~[na:na] at com.nerdwin15.stash.webhook.Notifier.notify(Notifier.java:112) ~[na:na] at com.nerdwin15.stash.webhook.Notifier.notify(Notifier.java:91) ~[na:na] at com.nerdwin15.stash.webhook.RepositoryChangeListener.onRefsChangedEvent(RepositoryChangeListener.java:51) ~[na:na] at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) ~[atlassian-event-2.3.1.jar:na] ... 6 common frames omitted 2014-01-28 08:52:19,001 ERROR [pool-15-thread-1] root 531x503x0 9pwfz0 178.25.57.214,127.0.0.1 "POST /rest/plugins/self-update/1.0/ HTTP/1.1" o.t.s.stash.web.admin.SgUpgradeJob writing logs to : /usr/local/stash/stash-home/data/repositories/11/subgit

mikesir87 commented 10 years ago

@tgruenert - this error is unfortunately something I can't fix by my code and looks to be a problem with your Java setup. Here's a few links on things to try -

http://askubuntu.com/questions/378497/eclipse-error-on-ubuntu-13-10 https://community.oracle.com/thread/1532568?tstart=4920

The general solution looks like checking the order of your security providers or by uninstalling and reinstalling Java. If that doesn't work, I'd be happy to help out, but will need to know some more details about your current setup (what platform are you running on, what version of Java, etc.).

tgruenert commented 10 years ago

Dear mikesir87, thank you for your suggestions . Today i retried the operation and it works out of the box. I dont know what changes are made at the system but for me it is always fine.

thank you again for your support, which is unbelievable fast and qualified.

Thomas