GitLab pipelines: using pvc mount for build_dir

Hello All,

I am using a self-managed GitLab instance having gitlab-runners set in Kubernetes with large git repositories. In our CI/CD pipeline, we have several stages where in a few stages jobs run in parallel.

To optimize performance, I am attempting to implement PVC mounts for the build_dir using the git fetch strategy. This approach aims to eliminate the need for each job to perform a new clone.

Problem: The stages consisting of a single job run without any issues. However, stages that contain multiple jobs intended to run in parallel are failing with the following error:

fatal: Unable to create ‘.git/index.lock’: File exists. Another git process seems to be running in this repository, e.g., an editor opened by ‘git commit’. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.

Would appreciate it if you could provide any feedback to resolve this issue.