Skip to content

Project Variables API should allow filtering/creating/updating/deleting by environment_scope

Summary

When talking to the API to fetch or create/update/delete project level variables it is not possible to filter variables based on environment_scope.

Steps to reproduce

Following the examples in the docs here: https://docs.gitlab.com/ce/api/project_level_variables.html it clearly shows that the endpoints do not accept environment_scope as a parameter for filtering, creating or updating variables.

What is the current bug behavior?

Not able to create or update variables with the correct scope. More so, when trying to delete a variable and there exists 2 variables with the same name for scope "production" and "staging" it is somewhat random in behavior in that it will either delete both of them or just a random one of the two. I think it has to do with the order of creating the variables so that it somehow fetches either the last or the first one and deletes that one. I did however, as I mentioned observe it deleting both of the variables.

What is the expected correct behavior?

  • List project variables for a desired scope. IE. staging vs production
  • Create variable with scope set
  • Update variable for set scope only
  • Delete variable for set scope only

Results of GitLab environment info

Using gitlab.com

Results of GitLab application Check

Using gitlab.com