How do I use GitLab Secrets Manager in a CI/CD job?
Short answer
Enable GitLab Secrets Manager for your top-level group (or instance), create a secret under Secure > Secrets manager, then request it in a job with the secrets keyword and gitlab_secrets_manager: name. The job gets a variable holding the path to a temporary file with the value, or the value itself with file: false. It became generally available in GitLab 19.5 on October 15, 2026, on Premium and Ultimate, and consumes GitLab Credits.
To use GitLab Secrets Manager in a job, create the secret under Secure > Secrets manager, then request it by name with the secrets keyword:
deploy:
secrets:
KUBE_CA_PEM:
gitlab_secrets_manager:
name: kube_cert
script:
- kubectl config set-cluster e2e --server="https://example.com" --certificate-authority="$KUBE_CA_PEM"
The job gets a KUBE_CA_PEM variable that holds the path to a temporary file containing the secret’s value. Jobs that don’t ask for the secret never see it.
GitLab Secrets Manager became generally available in GitLab 19.5, released on October 15, 2026. It’s on GitLab.com and GitLab Self-Managed, for the Premium and Ultimate tiers, as an add-on that consumes GitLab Credits. It’s built on OpenBao and uses your existing group and project permissions, so there’s no separate access model to maintain.
How is a secret different from a CI/CD variable?
A CI/CD variable is handed to jobs by default; a secret has to be requested by each job that needs it. That one difference is the point of the feature.
| CI/CD variable | Secrets Manager secret | |
|---|---|---|
| Reaches a job | By default | Only when the job lists it under secrets |
| Spaces and newlines | Not in a masked variable | Allowed, in values up to 10 KB |
A secret is also scoped to an environment, a branch or protected branches, its value can never be read back in the UI (you can only overwrite it), and every create, read, update and delete is written to the audit log.
If you’ve fought with variables that can’t be masked because the value holds a newline or a space, a secret takes those values as they are. If a job prints a secret’s value, GitLab replaces it in the job log with [MASKED].
How do I turn GitLab Secrets Manager on?
On GitLab.com you enable it once for a top-level group, and every subgroup and project under it can use it. You need the Owner role for that group.
- Open the top-level group and select Secure > Secrets manager.
- Select Enable with GitLab Credits.
- In the confirmation dialog, select Enable GitLab Secrets Manager.
If the subscription has no GitLab Credits available, the subscription owner first has to buy a monthly commitment or accept on-demand billing in the Customers Portal. You can also start a 30-day trial with temporary evaluation credits; when the trial ends, the Secrets Manager starts consuming credits.
On GitLab Self-Managed, only an administrator can turn it on, and the setting covers the whole instance. OpenBao must be installed and configured first, and the instance needs a Premium or Ultimate subscription. The switch is under Admin > Settings > General > GitLab Secrets Manager. An instance with an offline license can’t start a trial; its license has to include the add-on, and the administrator turns on the Secrets Manager toggle instead. Until it’s enabled, the Secrets manager item doesn’t appear in the left sidebar.
How do I create a secret?
Open the project or group, select Secure > Secrets manager, then New secret. The fields:
- Name: unique in that project or group, 255 characters or fewer, only letters, digits and underscores. You can’t rename a secret later.
- Value: 10 KB (10,000 bytes) or less.
- Description: up to 200 characters.
- Environments: all (
*, the default), one environment, or a wildcard. - Branches (projects only): a specific branch, or a wildcard containing
*. - Protected Branches (groups only, optional): export the secret only to pipelines on protected branches.
- Rotation reminder period (optional): an email reminder after a number of days, minimum 7.
A project secret can only be read by that project’s pipelines. A group secret can be read by pipelines in projects directly under the group or anywhere in its subgroups. The defaults allow 100 secrets per project and 500 per group.
Scope matters more than it looks: the value is available to every job that runs for the environment or branch on the secret, so anyone who can run a job there can read it. Tie production secrets to an environment or branch that only the right people can run pipelines on, such as a protected branch.
How do I read a secret in a job?
Use secrets with gitlab_secrets_manager, and name the secret. This needs GitLab Runner 19.0 or later. The key you choose (KUBE_CA_PEM in the first example) becomes the variable name; its value is the path to a temporary file, like a file-type CI/CD variable.
For a group secret, add source with the group/ prefix and the group’s full path:
deploy:
secrets:
KUBE_CA_PEM:
gitlab_secrets_manager:
name: kube_cert
source: group/my-group/my-subgroup
script:
- kubectl config set-cluster e2e --server="https://example.com" --certificate-authority="$KUBE_CA_PEM"
To get the value directly in the variable rather than a file path, set file: false on the secret:
deploy:
secrets:
DEPLOY_SECRET:
gitlab_secrets_manager:
name: deploy_credentials
file: false
script:
- my_deploy_command --user username --pass $DEPLOY_SECRET
Who can create and read secrets?
Owners manage it; Maintainers and Developers can add secrets by default. In a project, permissions live under Settings > General > Visibility, project features, permissions > GitLab Secrets Manager, and only the Owner role can change them.
| Role (project) | Default permissions |
|---|---|
| Owner | Everything, and can change the rules below |
| Maintainer | Read metadata, create, update (Secrets Managers enabled in GitLab 19.4 and later) |
| Developer | Read metadata, create; not update |
The scopes you can grant to a user or role are read metadata, read value, delete, create and update, each with an optional expiry date. Nobody can read a value back through the UI: editing a secret only overwrites it.
Why does the job fail to fetch the secret?
Almost always the secret isn’t where the job is looking, or the namespace has lost access.
| Error | Cause | Fix |
|---|---|---|
reading from Vault: api error: status code 403 ... permission denied |
The secret doesn’t exist or was deleted | Check the name, and source for group secrets |
configuring inline auth: inline auth JWT is required |
The Secrets Manager hasn’t been provisioned for that project or group yet | Create a secret there, then re-run the pipeline |
namespace does not have access to GitLab Secrets Manager |
Trial expired, no GitLab Credits, on-demand billing off, or the subscription lapsed | Start a trial or enable with GitLab Credits |
secret source group is not accessible from this project |
source names a group that isn’t the project’s group or a parent |
Change source, or limit the job with rules |
The last one is common with merge requests from forks, because the pipeline runs in the fork project. GitLab still creates the pipeline and only the jobs that use the secret fail. If the secret lives in the top-level group my-group, a rule such as if: $CI_PROJECT_ROOT_NAMESPACE == "my-group" keeps the job out of forks.
These failures are reported as ERROR: Job failed (system failure), so they read like a runner problem when they’re a configuration one. In MergeBell you can open the failed job’s log from the pipeline on your phone, read which of the four it is, and retry the job once the secret exists.
What happens to secrets when a project moves or is deleted?
They’re permanently deleted. Deleting or transferring a project or group disables its Secrets Manager and removes its secrets from the storage engine; secrets don’t follow a project to its new namespace. Copy the values somewhere safe before a transfer and re-create them afterwards.
Disabling the Secrets Manager is gentler: jobs that fetch secrets stop working, but GitLab keeps the secrets, and it stops consuming credits.
Checklist: moving a credential from a variable to a secret
- Secrets Manager is enabled for the top-level group or the instance
- The runner is GitLab Runner 19.0 or later
- The secret exists in the project, or in a group above it
- Its environment and branch scope match the jobs that need it
- Each job that needs it lists it under
secrets - Scripts read a file path, or the secret sets
file: false - The old CI/CD variable is deleted once the pipeline passes
Frequently asked questions
Is GitLab Secrets Manager generally available?
Yes. It became generally available in GitLab 19.5, released on October 15, 2026, on GitLab.com and GitLab Self-Managed for the Premium and Ultimate tiers. It is an add-on that consumes GitLab Credits, and there is a 30-day trial.
How is a secret different from a CI/CD variable?
A CI/CD variable is available to jobs by default. A secret must be requested by each job with the secrets keyword, is limited to the environments and branches set on it, can contain spaces and newlines, and every create, read, update and delete is written to the audit log.
Why does my job fail with "reading from Vault: api error: status code 403"?
The job asked for a secret that doesn't exist or has been deleted. Check the name under gitlab_secrets_manager against the secret list in Secure > Secrets manager, and for a group secret check the source path.
Can a job read a secret from a group?
Yes. Add source: group/<full-path-to-group> under gitlab_secrets_manager. The group must be the project's own group or one of its parent groups, so a pipeline in a fork that belongs to another group can't read it.
How many secrets can I store?
By default 100 per project and 500 per group. Secrets in a subgroup or member project don't count toward a parent group's limit. Each value can be up to 10 KB.
Sources
Checked against these pages on 23 November 2026. GitLab changes quickly — if something here no longer matches, tell us and we will fix it.
Do this from your phone with MergeBell
Free for the whole review loop: the To-Do inbox, diffs and line comments, approve and merge, pipelines with retry, and push alerts for your To-Dos. Works with gitlab.com and self-managed GitLab 16.0+.
Get MergeBell for iPhoneGet MergeBell for Android
On the App Store for iOS 26 or later and on Google Play for Android 12 or later. An independent app, not affiliated with GitLab Inc.