CI: Authenticate gitlab.com clones via GIT_CONFIG_GLOBAL file
What does this MR do?
Makes authenticated gitlab.com clones of gitlab-org/gitlab actually work, so they use the higher authenticated Gitaly rate limit instead of failing with GitLab is currently unable to handle this request due to load.
Why the previous attempts failed. The GIT_CONFIG_* variables added in 233dcc0121d6 never authenticated, for three compounding reasons:
- the
proactiveAuthkey was quoted (http."https://gitlab.com".proactiveAuth), which never matches the request URL; - the builder image shipped git 2.39.5, which predates
proactiveAuth(added in git 2.46); and - GitLab expands
${CI_JOB_TOKEN}when resolving thevariables:block — before the job token exists — so the credential helper baked in an empty password (confirmed via a debug job: token present andapi HTTP 200, but the helper returnedpassword: 0 chars).
!9501's URL-embedding workaround didn't help either: git never sends URL-embedded credentials preemptively (it waits for a 401, which gitlab.com never issues for a public repo).
This MR (adapts the approach from !9488):
- Writes the auth config to a file (
GIT_CONFIG_GLOBAL=/tmp/.gitconfig) inbefore_script, where the job token exists. A quoted heredoc keeps${CI_JOB_TOKEN}literal so the credential helper's shell expands it at clone time — the token never lands on disk.GIT_CONFIG_GLOBALis read by every git invocation, including those omnibus spawns. - Path-scopes
proactiveAuthtogitlab-org/gitlab— the only project the omnibus-gitlab CI job token is allowlisted for — so other gitlab.com mirrors keep cloning anonymously. The builder image now ships git 2.47.3, which supportsproactiveAuth. - Reverts
!9501(the URL-embedding inGitlab::Version#remote).
Related issues
Related to #9776. Supersedes !9488.
Edited by Stan Hu