Using external secrets in CI

Secrets represent sensitive information your CI job needs to complete work. This sensitive information can be items like API tokens, database credentials, or private keys. Secrets are sourced from your secrets provider.

Unlike CI/CD variables, which are always presented to a job, secrets must be explicitly required by a job. Read GitLab CI/CD pipeline configuration reference for more information about the syntax.

GitLab has selected as the first supported secrets engine.

GitLab authenticates using Vault’s CI_JOB_JWT) introduced in GitLab 12.10.

You must configure your Vault server before you can use use Vault secrets in a CI job.

The flow for using GitLab with HashiCorp Vault is summarized by this diagram:

Flow between GitLab and HashiCorp

  1. Configure your vault and secrets.
  2. Generate your JWT and provide it to your CI job.
  3. Runner contacts HashiCorp Vault and authenticates using the JWT.
  4. HashiCorp Vault verifies the JWT.
  5. HashiCorp Vault checks the bounded claims and attaches policies.
  6. HashiCorp Vault returns the token.
  7. Runner reads secrets from the HashiCorp Vault.
note
Read the Authenticating and Reading Secrets With HashiCorp Vault tutorial for a version of this feature. It’s available to all subscription levels, supports writing secrets to and deleting secrets from Vault, and supports multiple secrets engines.

Configure your Vault server

To configure your Vault server:

  1. Ensure your Vault server is running on version 1.2.0 or higher.
  2. Enable the authentication method by running these commands. They provide your Vault server the