Pre-receive hook isn't able to git clone
I'm trying to create a pre-receive hook but it isn't able to git clone after I push my commit in the terminal but when I try it on the Gitlab UI it works. The error is fatal: ref updates forbidden inside quarantine environment
Here is my code
#!/bin/bash
REPO=$PWD
check_lint_job () {
rev=$1
branch="$(git rev-parse --abbrev-ref $refname)"
workdir=$(mktemp -d gitXXXXXX)
(
trap "cd $REPO; rm -rf $workdir" EXIT > /dev/null 2>&1
unset GIT_DIR > /dev/null 2>&1
cd $workdir > /dev/null 2>&1
git clone $REPO check > /dev/null 2>&1
)
}
while read oldrev newrev refname; do
check_lint_job $newrev || exit 1
done
I tried the same thing using a post-receive hook and it works.