Skip to content

GitLab Next

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLab FOSSGitLab FOSS
  • Merge requests
  • !30779

Bring scoped environment variables to core

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Hordur Freyr Yngvason requested to merge bring-scoped-environment-variables-to-core into master Jul 16, 2019
  • Overview 18
  • Commits 5
  • Pipelines 32
  • Changes 31

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

port over occurrences variable_environment_scope in EE:

  • [?] 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:

Screenshot_2019-07-18_at_14.49.14

we got:

production job

  • ✅ PRODUCTION_ONLY_VARIABLE not present
  • ✅ STAGING_ONLY_VARIABLE present
  • ✅ PER_ENVIRONMENT_VALUE has production-specific value

Screenshot_2019-07-18_at_14.49.48

staging job

  • ✅ PRODUCTION_ONLY_VARIABLE not present
  • ✅ STAGING_ONLY_VARIABLE present
  • ✅ PER_ENVIRONMENT_VALUE has staging-specific value

Screenshot_2019-07-18_at_14.49.40

Edited Aug 05, 2019 by Hordur Freyr Yngvason
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: bring-scoped-environment-variables-to-core