Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
venkat230580 opened this issue Dec 17, 2019 · 1 comment

Comments

@venkat230580
Copy link

venkat230580 commented Dec 17, 2019

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:

  • Clone from BitBucket to local repo in the Jenkins server.
  • Make build and add tag to the cloned local repo.
  • Then push the newly added tag from local repo to BitBucket

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
Copy link
Member

seletskiy commented Dec 17, 2019

@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:

  • 6.2.5
  • 6.3.4
  • 6.4.2
  • 6.5.1

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: #60 (comment)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants