-
Notifications
You must be signed in to change notification settings - Fork 669
Group variable create
method does not set environment scope
#3138
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
Comments
I was checking out the code and noticed following differences between Group VS Project variables. The project variable manager is configured with the python-gitlab/gitlab/v4/objects/variables.py Lines 57 to 68 in cbc613d
But, the group variable manager doesn't set the python-gitlab/gitlab/v4/objects/variables.py Lines 41 to 50 in cbc613d
I looked through the history of the above code and noticed the group variable manger was always configured this way ( Also, GitLab supports more attributes for variables (i.e. |
@nejch - When you get a chance, could you please share your insight? Do you agree with my findings? I was thinking of opening a PR to fix it but wasn't sure about the tests. In this case, should it be in the unit test or functional test? My worry about unit test is that API responses are being mocked - so, the tests would easily pass even if I don't make any code change. Not sure what the general guideline is for testing. |
@amimas I'm not able to reproduce this myself, your snippet works without issue for me. However I'm also testing against GitLab 16.7.10. The following was run against a subgroup under a top level group: Stopping halfway through, the variables in the UI look correct I also tested first with python-gitlab 5.0.0, then also tested 5.6.0, no change in behavior. Is it possible this a GitLab licensing issue? Environment scope is only available (per the docs) for Premium and Ultimate customers |
Hi @holysoles - thanks for trying to reproduce it. I don't think it's a gitlab license issue. I had checked that too. I think I mentioned earlier that I was having difficulty reproducing the issue at first. After blowing away my venv and doing a fresh setup, I was able to reproduce it. Not sure why though. I linked another PR to this issue above. That's where I ran into it first and it's blocking that PR. That's why I tried to create a small reproducible script for this issue here. |
Thought I'd try again with a fresh environment. Unfortunately I'm still seeing the issue on my end. Here's what my python venv has:
I used GitLab version 17.9.0.
|
As a note the Feel free to do a PR to add them, as long as the upstream GitLab docs show they are valid. |
Description of the problem, including code/CLI snippet
The
create
method for group variables is not setting theenvironment_scope
attribute. I ran into the issue when attempting to create multiple CI CD variables at the group level where variable keys are same but has different scope.Below is a script that can reproduce the issue. It attempts to do the following:
environment_scope
definedTo run the script, first set the environment variables mentioned in the comments section and then execute
python <path-to-script.py>
.Expected Behavior
When
group.variables.create()
method is called, it should set/pass all the attributes to the GitLab API so that the variable is configured/created correctly.Actual Behavior
The
group.variables.create()
method is not configuring theenvironment_scope
. When running the sample script, it fails when creating the 2nd variable in the group. The error message will indicate that the failure is due to another variable with same key/name already exists:If we manually check the variable in the GitLab group (Group Settings -> CI CD -> Variables), we'll see the first variable being created but it does not have the environment scope - it's set to All environments as that's the default.
Specifications
The text was updated successfully, but these errors were encountered: