Skip to content

Commit 5706bec

Browse files
docs: variables: add note about filter for updating
Add a note about using `filter` when updating a variable. Closes: #2835 Closes: #1387 Closes: #1125
1 parent 44f62c4 commit 5706bec

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/gl_objects/variables.rst

+22
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,43 @@ Get a variable::
9090
p_var = project.variables.get('key_name')
9191
g_var = group.variables.get('key_name')
9292

93+
.. note::
94+
95+
If there are multiple variables with the same key, use ``filter`` to select
96+
the correct environment_scope. See the GitLab API docs for more information.
97+
9398
Create a variable::
9499

95100
var = project.variables.create({'key': 'key1', 'value': 'value1'})
96101
var = group.variables.create({'key': 'key1', 'value': 'value1'})
97102

103+
.. note::
104+
105+
If a variable with the same key already exists, the new variable must have a
106+
different environment_scope. Otherwise, GitLab returns a message similar to:
107+
VARIABLE_NAME has already been taken. See the GitLab API docs for more
108+
information.
109+
98110
Update a variable value::
99111

100112
var.value = 'new_value'
101113
var.save()
102114
# or
103115
project.variables.update("key1", {"value": "new_value"})
104116

117+
.. note::
118+
119+
If there are multiple variables with the same key, use ``filter`` to select
120+
the correct environment_scope. See the GitLab API docs for more information.
121+
105122
Remove a variable::
106123

107124
project.variables.delete('key_name')
108125
group.variables.delete('key_name')
109126
# or
110127
var.delete()
128+
129+
.. note::
130+
131+
If there are multiple variables with the same key, use ``filter`` to select
132+
the correct environment_scope. See the GitLab API docs for more information.

0 commit comments

Comments
 (0)