Closed
Description
Description of the problem, including code/CLI snippet
If environment scopes are used in project variables, modifying and saving a project variable with a specific "environment_scope" is always altering the variable with the last defined scope.
Example:
>>> variables = project.variables.list()
>>> for variable in variables:
... print("key: %s scope: %s" % (variable.key, variable.environment_scope))
...
key: SCOPE_VARIABLE scope: qa
key: SCOPE_VARIABLE scope: prod
key: SCOPE_VARIABLE scope: test
>>> for variable in variables:
... if variable.environment_scope == "prod":
... variable.value="new_value"
... variable.save()
... print(variable.attributes)
...
{'variable_type': 'env_var', 'key': 'SCOPE_VARIABLE', 'value': 'new_value', 'protected': False, 'masked': False, 'environment_scope': 'test', 'project_id': 123}
The variable with scope "prod" has not been modified, instead the variable with scope "test" is altered.
Expected Behavior
The variable with the specified scope should be updated.
Actual Behavior
The last scope defined for the variable is always taking precedence over the scope of the current variable that is going to be updated..
Specifications
- python-gitlab version: 2.3.1
- API version you are using (v3/v4): v4
- Gitlab server version (or gitlab.com): 13.0.5
Metadata
Metadata
Assignees
Labels
No labels