reconquest / atlassian-external-hooks

External Hooks plugin for Atlassian Bitbucket
https://external-hooks.reconquest.io
Other
45 stars 37 forks source link

External pre-receive hook stopped working when invoked from Jenkins Server #105

Open venkat230580 opened 4 years ago

venkat230580 commented 4 years ago

Hello,

For BitBucket, we have an external pre-receive hook that calls a shell script to make sure the new commit pushed to BitBucket does not contain folders/files that are now in the standard folder/file list. This hook should invoke the shell script for all the push regardless which git client is used.

This hook has been working fine all along, but starting yesterday, this hook stopped working for some critical situation. Basically if people use git clone/push with desktops, the hook still works. However, we have a Jenkins server to:

For the Jenkins server, the push would run the external pre-receive hook, but the hook failed to invoke the shell script and the push get rejected. We even changed the shell script to do nothing (empty script with only an exit command), the hook still fails. The BitBucket log shows the following error:

2019-12-16 13:42:30,821 WARN [hook-callback:thread-2] 4c007a74a48eb135 @19KAOF8x822x52184x1 5tezlw 165.112.229.65 SSH - git-receive-pack '/<bbproject>/<bbrepo>.git' c.a.s.i.h.r.DefaultRepositoryHoo kService [GRANTSMANAGEMENT/tcm[253]] Error calling com.atlassian.stash.internal.hook.script.ScriptRepositoryHook.preUpdate (com.atlassian.bitbucket.server.bitbucket-repository-hooks:script-repositor y-hook)java.lang.NullPointerException: null value in entry: BB_USER_EMAIL=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32)
at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:176)
at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:285)
at com.atlassian.stash.internal.hook.script.DefaultHookScriptEnvironmentProvider.userDetails(DefaultHookScriptEnvironmentProvider.java:203)
at com.atlassian.stash.internal.hook.script.DefaultHookScriptEnvironmentProvider.create(DefaultHookScriptEnvironmentProvider.java:115)
at com.atlassian.stash.internal.hook.script.DefaultHookScriptInvoker.lambda$prepareEnvironment$1(DefaultHookScriptInvoker.java:286)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
at com.atlassian.stash.internal.hook.script.DefaultHookScriptInvoker.prepareEnvironment(DefaultHookScriptInvoker.java:287)
at com.atlassian.stash.internal.hook.script.DefaultHookScriptInvoker.preUpdate(DefaultHookScriptInvoker.java:166)
at com.atlassian.stash.internal.plugin.OsgiSafeProxyProvider$1.invoke(OsgiSafeProxyProvider.java:95)
at com.atlassian.stash.internal.hook.script.ScriptRepositoryHook.preUpdate(ScriptRepositoryHook.java:49)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:770)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.lambda$preUpdate$4(DefaultRepositoryHookService.java:384)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:363)
at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36)
at com.atlassian.stash.internal.scm.git.GitQuarantineHelper.lambda$null$1(GitQuarantineHelper.java:106)
at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:301)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:287)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:221)
at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.lang.Thread.run(Thread.java:748)
... 34 frames trimmed
2019-12-16 13:42:30,821 INFO [hook-callback:thread-2] 4c007a74a48eb135 @19KAOF8x822x52184x1 5tezlw 165.112.229.65 SSH - git-receive-pack '/<bbproject>/<bbrepo>.git' c.a.s.i.h.r.DefaultRepositoryHookService [<BBPROJECT/<BBREPO>[253]] hook 'script-repository-hook' vetoed the push request

This is a show-stopper issue that basically stopped all our build process with Jenkins. Please help.

BTW, here are some of the general info: BitBucket DataCenter version: 6.3.1 BitBucket server git version: 2.18.0 Jenkins server git version: 2.19.1-412

Thanks Venkat

seletskiy commented 4 years ago

@venkat230580: Hello.

This is bug in Bitbucket (not in External Hooks add-on) and it was fixed in 6.6.0 with backport made to the following versions:

Since you're using Bitbucket 6.3.1 it seems that you need to upgrade Bitbucket installation to at least to 6.3.4 to get this fixed.

Related thread: https://github.com/reconquest/atlassian-external-hooks/issues/60#issuecomment-513204929

Related Bitbucket ticket: https://jira.atlassian.com/browse/BSERV-11869