CI/CD Variables#
You can configure variables at the instance-level (admin only), or associate variables to projects and groups, to modify pipeline/job scripts behavior.
Instance-level variables#
This endpoint requires admin access.
Reference#
Examples#
List all instance variables:
variables = gl.variables.list()
Get an instance variable by key:
variable = gl.variables.get('key_name')
Create an instance variable:
variable = gl.variables.create({'key': 'key1', 'value': 'value1'})
Update a variable value:
variable.value = 'new_value'
variable.save()
Remove a variable:
gl.variables.delete('key_name')
# or
variable.delete()
Projects and groups variables#
Reference#
v4 API
GitLab API
Examples#
List variables:
p_variables = project.variables.list()
g_variables = group.variables.list()
Get a variable:
p_var = project.variables.get('key_name')
g_var = group.variables.get('key_name')
Create a variable:
var = project.variables.create({'key': 'key1', 'value': 'value1'})
var = group.variables.create({'key': 'key1', 'value': 'value1'})
Update a variable value:
var.value = 'new_value'
var.save()
# or
project.variables.update("key1", {"value": "new_value"})
Remove a variable:
project.variables.delete('key_name')
group.variables.delete('key_name')
# or
var.delete()