title: GitLab global post-receive server hook for all repositories not executed after CI job completion
body: <h2>Context</h2>
  <p>After setting up a GitLab server, GitLab runner CI, and creating a test-repository that completes a CI-job successfully, I was experiencing some difficulties in ensuring a <code>post-receive</code> script is completed after the CI is finished successfully on the test repository commit.</p>
  <h2>MWE</h2>
  <p>The MWE does the complete deployment, and uploads a repository to the GitLab server and runs the CI on the repository. However, it is not yet generalised well, hence it has (at least) the following requirements: System: Ubuntu 20.04, Architecture:AMD64.</p>
  <pre><code>git clone git@github.com:Deployment-Oneliners/Self-host-GitLab-Server-and-Runner-CI.git
  cd Self-host-GitLab-Server-and-Runner-CI
  git checkout post-receive
  rm -r test/libs/*
  chmod +x install-bats-libs.sh
  ./install-bats-libs.sh
  ./install_gitlab.sh -s -r
  ./test.sh
  ./test/libs/bats/bin/bats test/test_post_receive.bats
  </code></pre>
  <p>One would expect the <code>post-receive</code> job to create a file on <code>/home/&lt;your ubuntu username&gt;/Desktop/helloworld.txt</code>. (Which it does not, I assume because the <code>post-receive</code> script is not ran.)</p>
  <p>To uninstall the MWE completely, one can run: <code>./uninstall_gitlab.sh -y -h -r</code>.</p>
  <h2>Issue</h2>
  <ol>
  <li>The documentation says</li>
  </ol>
  <ul>
  <li>For an installation from source is usually /home/git/gitlab-shell/hooks.</li>
  <li>For Omnibus GitLab installs is usually /opt/gitlab/embedded/service/gitlab-shell/hooks.</li>
  </ul>
  <p>However, for the used deployment script, this is <code>/home/name/gitlab/data/gitlab-shell</code> instead. Hence, I assumed that <code>/home/name/gitlab/data/gitlab-shell/hooks</code> is the default hooks directory.</p>
  <p>I tested this hypothesis by creating a <code>post-receive/post-receive</code> directory and script, ensured they were owned by the <code>gitlab-runner</code> user, and runnable, and making a new commit such that the CI would complete again. The <code>post-receive</code> script was not executed by GitLab.</p>
  <p>Next, I logged into the docker and found the actual <code>gitlab-shell</code> folder using:</p>
  <pre><code>sudo docker ps -a
  docker exec -t -i 0f17db17c212 /bin/bash
  cd /opt/gitlab/embedded/service/gitlab-shell/
  mkdir hooks
  cd hooks
  mkdir post-receive.d
  cd post-receive.d
  echo '#!/bin/bash' | tee post-receive
  echo 'touch server_example_output.txt' | tee -a tee post-receive
  chmod +x post-receive
  </code></pre>
  <p>and verified the <code>post-receive</code> script creates a file called: <code>example_output.txt</code> in the same folder as the script (since I can't reach out to the linux user from inside the docker). I did not know how to make the <code>post-receive</code> owned by <code>gitlab-runner</code> as the <code>chown</code> command did not work because it says the <code>gitlab-runner</code> user is not found. I assume this is because the root acount inside the docker is actually the <code>gitlab-runner</code> account. The content of the <code>post-receive</code> script inside the docker is:</p>
  <pre><code>#!/bin/bash
  touch server_example_output.txt
  </code></pre>
  <p>and it was manually verified using: <code>./post-receive</code> which created the <code>example_output.txt</code> file. However, running the CI on a new commit did not result in the creation of that output file.</p>
  <p>Additionally, I tried to create a <code>post-receive</code> script inside the docker for a particular repository . This was successful and I learned that the script is ran from the root of the directory, so if you write <code>touch output.txt</code> the file will not be created in <code>/hooks/output.txt</code>, but in the hashed <code>&lt;long hash code&gt;.git/</code> directory.</p>
  <h2>Question</h2>
  <p>How can I ensure the GitLab <code>post-receive</code> script is executed after a repository commit is performed in the GitLab server? (Is there some gui/button in the GitLab server that allows one to test whether the <code>post-receive</code> script is found by GitLab and executable)?</p>