If you find yourself here in 2025, add these lines to your gitlab-ci.yml stage:
hooks: pre_get_sources_script: - sudo chown -R gitlab-runner:gitlab-runner .
The "pre_clone_script" tag in the accepted answer is now deprecated.