| title | `glab deploy-token create` |
|---|---|
| stage | AI Clients |
| group | Developer Clients |
| info | To determine the technical writer assigned to the Stage/Group associated with this page, see <https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments> |
Create a deploy token.
Create a deploy token for a project or a group.
The token value is printed only once, when the token is created, and cannot be retrieved later. Use --output json to capture it from a script.
A deploy token authenticates as a username and token pair, so both values from the output are needed to use it.
The token does not expire unless --expires-at is given.
Every token must be granted at least one scope with --scope. For the scopes you can grant, see https://docs.gitlab.com/user/project/deploy_tokens/#scope.
glab deploy-token create <name> [flags]
# Create a read-only deploy token for the current project
glab deploy-token create ci-reader --scope read_repository
# Create a token that can also pull images from the container registry
glab deploy-token create ci-reader --scope read_repository --scope read_registry
# Create a token for a specific project, with a custom username
glab deploy-token create ci-reader --scope read_repository --username ci-reader --repo user/my-repo
# Create a token that is valid until the end of 2027
glab deploy-token create ci-reader --scope read_repository --expires-at 2028-01-01
# Create a group deploy token
glab deploy-token create ci-reader --scope read_repository --group group/sub-group
# Create the token that CI/CD jobs receive as CI_DEPLOY_USER and CI_DEPLOY_PASSWORD
glab deploy-token create gitlab-deploy-token --scope read_registry
# Create a token and print its username and value from a script
glab deploy-token create ci-reader --scope read_repository --output json --jq '"\(.username) \(.token)"' -E, --expires-at time Expiry of the token, as YYYY-MM-DD (00:00 UTC) or an RFC 3339 timestamp. The token does not expire if omitted.
-g, --group group Create a deploy token for a group instead of a project. Accepts a group ID or full path.
--jq string Filter JSON output with a jq expression.
-F, --output string Format output as: text, json. (default "text")
-R, --repo string Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.
-S, --scope strings Scope to grant the token. Multiple scopes can be comma-separated or specified by repeating the flag.
--username string Username for the token. Defaults to 'gitlab+deploy-token-<id>'.
-h, --help Show help for this command.