Skip to content
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

update CI/CD Variables with a specific env #2835

Closed
bungeetux opened this issue Apr 4, 2024 · 0 comments · Fixed by #2927
Closed

update CI/CD Variables with a specific env #2835

bungeetux opened this issue Apr 4, 2024 · 0 comments · Fixed by #2927

Comments

@bungeetux
Copy link

bungeetux commented Apr 4, 2024

Description of the problem, including code/CLI snippet

When trying to update a variable with an environment set, the variable could not be updated as mention in the documentation
https://python-gitlab.readthedocs.io/en/stable/gl_objects/variables.html
you need to add a filter as the gitlab api endpoint mention it in https://docs.gitlab.com/ee/api/project_level_variables.html#update-a-variable

It could be added to the documentation or fix in the code, as you could assume that you would never change the environment of a variable.

  for var in project.variables.list():  
    if var.environment_scope == env:
      if var.key == name:
        print('Variable found')
        print(var)
        var.value = value
        **var.filter = {'environment_scope': env}** # necessary to update a variable that has multiple environnements
        var.save()
        print('Variable updated')

Expected Behavior

variable updated

Actual Behavior

gitlab.exceptions.GitlabUpdateError: 409: There are multiple variables with provided parameters. Please use 'filter[environment_scope]'

Specifications

  • python-gitlab version: 4.2.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): gitlab.com
JohnVillalovos added a commit that referenced this issue Jul 13, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
JohnVillalovos added a commit that referenced this issue Jul 13, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
JohnVillalovos added a commit that referenced this issue Jul 13, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
Closes: #1387
JohnVillalovos added a commit that referenced this issue Jul 13, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
Closes: #1387
Closes: #1125
JohnVillalovos added a commit that referenced this issue Jul 13, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
Closes: #1387
Closes: #1125
JohnVillalovos added a commit that referenced this issue Jul 13, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
Closes: #1387
Closes: #1125
JohnVillalovos added a commit that referenced this issue Jul 15, 2024
Add a note about using `filter` when updating a variable.

Closes: #2835
Closes: #1387
Closes: #1125
@nejch nejch closed this as completed in c378817 Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant