Skip to content

Add `environment_scope` to `VariableType`

Avielle Wolfe requested to merge add-environment-scope-to-variable-type into master

What does this MR do and why?

This MR adds an environment_scope field to VariableType. The field will be populated for variables fetched from projects and groups. Variables fetched from QueryType will have null as the value, since instance level variables do not have an environment scope.

How to set up and validate locally

Create some variables

  • In a project's CI/CD settings /NAMESPACE/PROJECT/-/settings/ci_cd, create a project variable. Assign it any environment scope. If there are no environments, create one by entering a value in the dropdown and selecting Create wildcard
  • In a group's CI/CD settings /groups/GROUP/-/settings/ci_cd, create a group variable. Assign it any environment scope. If there are no environments, create one by entering a value in the dropdown and selecting Create wildcard
  • In the admin CI/CD settings admin/application_settings/ci_cd, create an instance variable. Instance variables will always be the default environment scope *

Query for the variables

Using /-/graphql-explorer:


Query for the project variable:

{
  project(fullPath: "NAMESPACE/PROJECT") {
    ciVariables {
      nodes {
        environmentScope
        key
      }
    }
  }
}

See that the environmentScope is the same as the environment scope set on the variable


Query for the group variable:

{
  group(fullPath: "NAMESPACE") {
    ciVariables {
      nodes {
        key
        environmentScope
      }
    }
  }
}

See that the environmentScope is the same as the environment scope set on the variable


Query for the instance variable:

{
  ciVariables {
    nodes {
      key
      environmentScope
    }
  }
}

See that the environmentScope for all variables is null

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Avielle Wolfe

Merge request reports

Loading