What does this MR do?
Addresses https://gitlab.com/gitlab-org/gitlab-ce/issues/53593
EE MR: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14729
(EE feature originally introduced in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2112/diffs)
TODO
variable_environment_scope
in EE:
port over occurrences - [?] doc/development/ee_features.md -- Do we need another example feature instead?
-
ee/app/controllers/ee/projects/variables_controller.rb -
ee/app/models/ee/project.rb - [?] ee/app/models/license.rb -- not relevant for CE?
-
ee/app/serializers/ee/variable_entity.rb -
ee/app/views/ci/variables/_environment_scope.html.haml -
ee/lib/ee/api/entities.rb -
ee/lib/ee/api/variables.rb -
ee/spec/controllers/projects/variables_controller_spec.rb -
ee/spec/features/project_variables_spec.rb -
ee/spec/lib/gitlab/ci/build/policy/variables_spec.rb -
ee/spec/models/ci/build_spec.rb -
ee/spec/models/project_spec.rb -
ee/spec/requests/api/variables_spec.rb -
ee/spec/serializers/variable_entity_spec.rb - [?] spec/javascripts/fixtures/projects.rb -- I don't think we need to stub the feature because it's now in core
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Manual QA
With the following .gitlab-ci.yml
:
.base: &base
script:
- echo production-only $PRODUCTION_ONLY_VARIABLE
- echo staging-only $STAGING_ONLY_VARIABLE
- echo per-environment-value $PER_ENVIRONMENT_VALUE
production:
<<: *base
environment:
name: production
staging:
<<: *base
environment:
name: staging
with environments staging
and production
, and the following environment specific variables:
we got:
production job
-
✅ PRODUCTION_ONLY_VARIABLE
not present -
✅ STAGING_ONLY_VARIABLE
present -
✅ PER_ENVIRONMENT_VALUE
has production-specific value
staging job
-
✅ PRODUCTION_ONLY_VARIABLE
not present -
✅ STAGING_ONLY_VARIABLE
present -
✅ PER_ENVIRONMENT_VALUE
has staging-specific value