Add CI_PROJECT_NAMESPACE_ID to predefined variables
What does this MR do and why?
As we include this ID in the JWT claims (used to authenticate to Cloud services like Vault), having it in the CI allows jobs to leverage this ID to access secrets or other resources.
Closes #375355 (closed)
For example, let's imagine we have this Vault JWT auth claim mappings:
{
"namespace_id": "gitlab_namespace_id",
"project_id": "gitlab_project_id"
}
and Vault ACL policy:
{
description = "Allow per namespace/project CI secrets"
path = "secrets/data/{{identity.entity.aliases.$ACCESSOR.metadata.gitlab_namespace_id}}/{{identity.entity.aliases.$ACCESSOR.metadata.gitlab_project_id}}/ci"
capabilities = ["read", "list"]
}
We'll be able to achieve this:
vault write -field=token auth/jwt/login role=gitlab jwt=$CI_JOB_JWT
export PASSWORD=$(vault kv get -field=password secrets/$CI_PROJECT_NAMESPACE_ID/$CI_PROJECT_ID/ci)
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Adrien F