Embed CI job token in alternative gitlab.com source URLs
What does this MR do?
The alternative source channel returns plain HTTPS gitlab.com URLs and relies on http.<url>.proactiveAuth + a credential helper (configured via GIT_CONFIG_*) to authenticate clones so they get the higher authenticated Gitaly rate limit. That approach is fragile:
- it silently no-ops on
git < 2.46(the builder image currently ships 2.39.5), so auth is never sent; - the credential-helper resolution is easy to misconfigure; and
- unauthenticated clones of
gitlab-org/gitlabhit the lower anonymous Gitaly rate limit (fatal: remote error: GitLab is currently unable to handle this request due to load).
Instead, this MR mirrors what the security channel already does and embeds the token directly in the URL via attach_remote_credential, so authentication is sent on the very first request regardless of git version.
To stay safe, the credential is only attached when both conditions hold:
- the component is in
CREDENTIALED_ALTERNATIVE_SOFTWARE(currently justgitlab-rails-ee) — the only project the omnibus-gitlab CI job token is allowlisted for. Other gitlab.com mirrors (gitaly, gitlab-shell, …) keep cloning anonymously, which is required since the token is rejected for projects it isn't allowlisted for; and - the URL is an HTTPS gitlab.com URL — SSH remotes (where the credential is useless and would mangle the URL) and any other host are left untouched, so the token can never leak off-host if a source is changed.
ALTERNATIVE_PRIVATE_TOKEN is preferred over CI_JOB_TOKEN when set, matching the existing env-override path.
This also covers the generate-facts job, whose omnibus manifest gitlab step resolves the source URL through Gitlab::Version#remote.
Related issues
Related to #9776.
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion.
Required
- MR title and description are up to date, accurate, and descriptive.
- MR targeting the appropriate branch.
- Latest Merge Result pipeline is green.
- When ready for review, MR is labeled workflowready for review per the Distribution MR workflow.
For GitLab team members
If you don't have access to this, the reviewer should trigger these jobs for you during the review process.
- The manual
Trigger:ee-packagejobs have a green pipeline running against latest commit. - If
config/softwareorconfig/patchesdirectories are changed, make sure thebuild-package-on-all-osjob within theTrigger:ee-packagedownstream pipeline succeeded. - If you are changing anything SSL related, then the
Trigger:package:fipsmanual job within theTrigger:ee-packagedownstream pipeline must succeed. - If CI configuration is changed, the branch must be pushed to
dev.gitlab.orgto confirm regular branch builds aren't broken.
Expected (please provide an explanation if not completing)
- Test plan indicating conditions for success has been posted and passes.
- Documentation created/updated.
- Tests added.
- Integration tests added to GitLab QA.
- Equivalent MR/issue for the GitLab Chart opened.
- Validate potential values for new configuration settings. Formats such as integer
10, duration10s, URIscheme://user:passwd@host:portmay require quotation or other special handling when rendered in a template and written to a configuration file.