ci_variables

Create a variable

Creates a variable. If a variable with the same key already exists, the variable must have a different environment_scope. Otherwise, GitLab returns a message similar to: VARIABLE_NAME has already been taken.

post/api/v4/projects/{id}/variables

Request

  • Base URL
    https://gitlab.com
  • Auth
    none declared

Path parameters

idstring required

The ID of a project or URL-encoded NAMESPACE/PROJECT_NAME of the project owned by the authenticated user

Request body

keystring required

The key of a variable

valuestring required

The value of a variable

protectedboolean

Whether the variable is protected

maskedboolean

Whether the variable is masked

masked_and_hiddenboolean

Whether the variable is masked and hidden

rawboolean

Whether the variable will be expanded

variable_type'env_var' | 'file'

The type of the variable. Default: env_var

environment_scopestring

The environment_scope of the variable

descriptionstring

The description of the variable

Response

Create a variable

variable_typestring required
keystring required
valuestring required
hiddenboolean
protectedboolean
maskedboolean
rawboolean
environment_scopestring
descriptionstring

Example response

{
  "variable_type": "env_var",
  "key": "TEST_VARIABLE_1",
  "value": "TEST_1",
  "environment_scope": "*",
  "description": "This variable is being used for ..."
}

Changes

No recorded changes to this operation across all 5 revisions of this API.