Hi,
We are trying to implement a pre receive hook at repository level. We want to reject push that contains sql files having blacklisted keywords. Currently don't see an option to enable/add custom pre-receive hook via Bitbucket UI.
Following the shell script we used as pre-commit hook in local repo.
########################
#!/bin/bash
LIST="DROP|COMMIT|TRUNCATE|ROLLBACK"
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
for FILE in `git diff-index -name-status --cached $against – | cut -c3 | grep -E 'dbsql'` ; do
#Check if the file contains one of the words in LIST
if grep -iwE $LIST $FILE; then
echo $FILE." has one of the following blacklisted keywords you don't want to commit. Please remove it"
echo "Blacklisted keywords : DROP|COMMIT|TRUNCATE|ROLLBACK"
exit 1
fi
done
exit
##########################################
We have few questions:
a) Is it possible to add custom pre-receive hooks via bitbucket UI and provide the content as shell script?
b) Is it mandatory that content of pre-receive hook should be written in groovy scripting language?
Current setup:
Current pre hook settings in UI are below

When we click add hook, it is re-directing to market place.
Our use case : We want developers to block pushing the sql files having blacklisted keywords like DROP,COMMIT etc at bitbucket server side.