Skip to content

Implement CI syntax for secrets

Krasimir Angelov requested to merge ci-secrets-syntax into master

What does this MR do?

This MR adds initial support for configuring job's secrets in CI yaml. Built on top of !31831 (closed) with the changes suggested in #218746 (closed).

This new syntax is hidden behind global (instance wide) feature flag named ci_secrets_syntax, disabled by default.

The syntax look like this:

  stage: release
      vault: production/db/password         # translates to secret `kv-v2/data/production/db`, field `password`
      vault: production/ssl/private-key@ops # translates to secret `ops/data/production/ssl`, field `private-key`
    S3_SECRET_KEY:                          # translates to secret `aws/data/production/s3`, field `secret-key`
          name: kv-v2
          path: aws
        path: production/s3
        field: secret-key

Here is a test the cover the above forms of the syntax -

The processed config will be returned to the runner (to be implemented in a subsequent MR) where it will be used to fetch the secrets from Vault, see gitlab-runner!2006 (closed).

This will be GitLab Premium feature, the license check will be added in a subsequent MR at the API level so that we can scope to a project.


In this case vault is a static keyword that represents the secrets provider type. While it will allow us to add another type of provider in the future, it prevents us to have multiple providers of the same type, for example db-vault, ops-vault, etc, something that was supported with the syntax implemented in !31831 (closed).


ci_secrets_syntax feature flag disabled


ci_secrets_syntax feature flag enabled


Does this MR meet the acceptance criteria?


Availability and Testing


If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Krasimir Angelov

Merge request reports