Since upgrading from stash to bitbucket server the post-receive hooks don't fire anymore.
This appears in the logfile:
2016-03-01 14:24:33,034 ERROR [AtlassianEvent::thread-1] user.name @1LE1CN3x864x111801x0 13411v6 192.168.17.209,127.0.0.1 "POST /rest/branch-utils/latest/projects/PN/repos/site/branches HTTP/1.1" c.n.s.e.hook.ExternalPreReceiveHook Error running [/bin/sh, /var/git/repos/pn-site/hooks/post-receive] in /var/bitbucket/data/shared/data/repositories/12
java.io.IOException: Broken pipe
at java.io.FileOutputStream.writeBytes(Native Method) ~[na:1.8.0_72]
at java.io.FileOutputStream.write(FileOutputStream.java:326) ~[na:1.8.0_72]
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[na:1.8.0_72]
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) ~[na:1.8.0_72]
at java.io.FilterOutputStream.close(FilterOutputStream.java:158) ~[na:1.8.0_72]
at com.ngs.stash.externalhooks.hook.ExternalPreReceiveHook.onReceive(ExternalPreReceiveHook.java:133) ~[plugin.793156020221014809.external-hooks-3.0-1_1453796236000.jar:na]
at com.ngs.stash.externalhooks.hook.ExternalAsyncPostReceiveHook.postReceive(ExternalAsyncPostReceiveHook.java:46) [plugin.793156020221014809.external-hooks-3.0-1_1453796236000.jar:na]
at com.atlassian.stash.internal.hook.repository.AsyncPostReceiveRepositoryHookAdapter$1.visit(AsyncPostReceiveRepositoryHookAdapter.java:49) [bitbucket-service-impl-4.3.0.jar:na]
at com.atlassian.stash.internal.hook.repository.AsyncPostReceiveRepositoryHookAdapter$1.visit(AsyncPostReceiveRepositoryHookAdapter.java:45) [bitbucket-service-impl-4.3.0.jar:na]
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService$RepositoryHookPagedTransactionCallback.doInTransaction(DefaultRepositoryHookService.java:574) [bitbucket-service-impl-4.3.0.jar:na]
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService$RepositoryHookPagedTransactionCallback.doInTransaction(DefaultRepositoryHookService.java:550) [bitbucket-service-impl-4.3.0.jar:na]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) [spring-tx-4.2.2.RELEASE.jar:na]
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.visitEnabledHooks(DefaultRepositoryHookService.java:280) [bitbucket-service-impl-4.3.0.jar:na]
at com.atlassian.stash.internal.hook.repository.AsyncPostReceiveRepositoryHookAdapter.postReceive(AsyncPostReceiveRepositoryHookAdapter.java:45) [bitbucket-service-impl-4.3.0.jar:na]
at com.atlassian.stash.internal.hook.repository.AsyncPostReceiveRepositoryHookAdapter.onRefsChangedEvent(AsyncPostReceiveRepositoryHookAdapter.java:40) [bitbucket-service-impl-4.3.0.jar:na]
at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:36) [atlassian-event-3.0.0.jar:na]
at com.atlassian.stash.internal.event.AsyncBatchingInvokersTransformer$AsyncInvokerBatch.invoke(AsyncBatchingInvokersTransformer.java:94) [bitbucket-platform-4.3.0.jar:na]
at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1$1.run(AsynchronousAbleEventDispatcher.java:46) [atlassian-event-3.0.0.jar:na]
at com.atlassian.sal.core.executor.ThreadLocalDelegateRunnable.run(ThreadLocalDelegateRunnable.java:34) [sal-core-3.0.5.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_72]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_72]
... 29 frames trimmed
On the shell, switching to the bitbucket user and going to the /var/bitbucket/data/shared/data/repositories/12 directory and running /bin/sh /var/git/repos/pn-site/hooks/post-receive FOO BAR BAZ works fine.
Found it.
I had to set default !requiretty for my bitbucket user in the sudoers file.
The old stash user had that because my script needs both sudo and ssh.
Since upgrading from stash to bitbucket server the post-receive hooks don't fire anymore.
This appears in the logfile:
On the shell, switching to the bitbucket user and going to the /var/bitbucket/data/shared/data/repositories/12 directory and running
/bin/sh /var/git/repos/pn-site/hooks/post-receive FOO BAR BAZ
works fine.Any suggestions?