Skip to content

Expose deploy token to CI/CD jobs as environment variable

Description

Deploy tokens (https://gitlab.com/gitlab-org/gitlab-ce/issues/31591) allow easy read-only access to the repo or registry in a permanent way, so they can be used when the project is private/internal and we want to create Kubernetes credentials that will be valid also after the job is finished.

Proposal

Automatically expose a deploy token with a specific name to CI/CD jobs in an environment variables. In a similar way, we want also to expose the related username.

If a deploy token with name gitlab-deploy-token exists for the project, expose the following variables:

  • CI_DEPLOY_USER: 'gitlab-deploy-token'
  • CI_DEPLOY_PASSWORD: value of the token