8000 docs: variables: add note about `filter` for updating by JohnVillalovos · Pull Request #2927 · python-gitlab/python-gitlab · GitHub
[go: up one dir, main page]

Skip to content

docs: variables: add note about filter for updating #2927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000 Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/gl_objects/variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,46 @@ Get a variable::
p_var = project.variables.get('key_name')
g_var = group.variables.get('key_name')

.. note::

If there are multiple variables with the same key, use ``filter`` to select
the correct ``environment_scope``. See the GitLab API docs for more
information.

Create a variable::

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

.. note::

If a variable with the same key already exists, the new variable must have a
different ``environment_scope``. Otherwise, GitLab returns a message similar
to: ``VARIABLE_NAME has already been taken``. See the GitLab API docs for
more information.

Update a variable value::

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

.. note::

If there are multiple variables with the same key, use ``filter`` to select
the correct ``environment_scope``. See the GitLab API docs for more
information.

Remove a variable::

project.variables.delete('key_name')
group.variables.delete('key_name')
# or
var.delete()

.. note::

If there are multiple variables with the same key, use ``filter`` to select
the correct ``environment_scope``. See the GitLab API docs for more
information.
0