Symptoms:
1) ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://x@x:7990/bitbucket/scm/x/x.git'
I also get the warning:
2) Git hook scripts are not executing
In the BitBucket support page
3) In atlassian-bitbucket.log
2018-08-07 08:10:25,175 WARN [http-nio-7990-exec-9] "POST /scm/fixa/repo.git/git-receive-pack HTTP/1.1" c.a.s.i.s.g.p.http.HttpReceivePack PROJ/repo[1]: Git hooks have not been called. Please verify that the hooks are configured correctly - see https://confluence.atlassian.com/display/BITBUCKETSERVERKB/Git+hook+scripts+are+not+executing?utm_campaign=in-app-help&utm_medium=in-app-help&utm_source=stash for details
But the link only refer to chmod stuff in Linux, and I made sure that bitbucket user have access to the ApplicationData folder.
4)
I see all the githook files, but when I try to run them in git-bash
user@COMPUTER MINGW64
/c/Atlassian/ApplicationData/Bitbucket/shared/data/repositories/1/hooks (BARE:master)
$ ./pre-receive
./pre-receive: line 9: /c/Atlassian/ApplicationData/Bitbucket/shared/data/reposi tories/1/hooks/hooks/pre-receive.d: No such file or directory
Note the extra hooks in the path. If I manually remove this in the pre-receive script I get:
$ ./pre-receive./pre-receive: line 11: exec: pre-receive.d: cannot execute: Is a directory
#!/usr/bin/env bash
#>*******************************************************
# THIS FILE WAS AUTO-GENERATED BY ATLASSIAN BITBUCKET.
# IT CONTAINS NO USER-SERVICEABLE PARTS.
#>*******************************************************
if [[ "$OSTYPE" == "cygwin" ]]; then
exec $(cygpath $STASH_HOOK_COORDINATOR) hooks/pre-receive.d "$@" <&0 >&1 2>&2
else
exec $STASH_HOOK_COORDINATOR hooks/pre-receive.d "$@" <&0 >&1 2>&2
fi
Hooks location
Above is the default pre-receive scrip
5)
C:\Atlassian\ApplicationData\Bitbucket\shared\data\repositories\1\hooks
I made sure that the bitbucket owner account have full rights to the folders
This is repeated for every new repo I create.
What bash/git instance bitbucket supposed to use? Its own or a pre-install one? Could it be a problem with previous installations of git on the server prior to bitbucket?
Thank you for any help
Hey Oscar,
The scripts that are actually being executed exist in the path:
/c/Atlassian/ApplicationData/Bitbucket/shared/data/repositories/1/hooks/hooks/pre-receive.d
The file structure needs to be accessible by the user running Bitbucket Server, and the resulting files in that path need to be executable. If you are on an NFS mount you will need to make sure that it was mounted with exec, as noted in the reference KB.
If you look in the pre-receive.d folder, you should see a file called "20_stash_callback" - this file needs to be executable and accessible to the user running Bitbucket Server.
The failure from your manual execution is due to it being executed within the hooks directory as the script references that the execution path is in "hooks", therefore, it is forming an executable path that doesn't exist:
.../shared/data/repositories/1/hooks/hooks/pre-receive.d/
If you were going to manually execute, you would do so from:
.../shared/data/repositories/1/
I would also avoid using "./" in the command as well as that could contribute.
Clarifying Questions
Let's verify that the files themselves are actually executable. Please also check any potential policies being executed via registry that could be impacting you. I've worked a similar case in which the issue boiled down to permissions and restrictions instituted at the registry level.
This is a new installation on windows server. I noticed that I couldn't push anything to the created repos.
When running the scripts from the correct path I again get the error
$ hooks/pre-receive
hooks/pre-receive: line 9: /c/Atlassian/ApplicationData/Bitbucket/shared/data/repositories/1/hooks/pre-receive.d: Is a directory
hooks/pre-receive: line 9: exec: /c/Atlassian/ApplicationData/Bitbucket/shared/data/repositories/1/hooks/pre-receive.d: cannot execute: Is a directory
pre-receive.d shows up as a folder in my NTFS (this is a windows server), and inside the directory lies a file 20_bitbucket_callback.
The jire user account do have read and write and exec access to the folders.
Just to try stuff I moved the script from the folder pre-receive.d to the hooks directory and ran it. Now I got Another error exec: git-pre-receive: not found.
I really want bitbucket to work and our Company have a no cloud based data policy.
Thanks for any help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Oscar,
I am not sure why the Jira user would need access to those folders unless you've modified your installation to be run under user "jira" otherwise, the default user is "atlbitbucket" if you chose to install Bitbucket as a service.
Have you checked your security policies on your server to see if they are preventing the executing of the hooks?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.