Skip to content

GitLab Next

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

Merged
Created Jul 16, 2019 by Hordur Freyr Yngvason@hfyngvasonDeveloper14 of 25 tasks completed14/25 tasks

Bring scoped environment variables to core

  • 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
12.2
Milestone
12.2 (Past due)
Assign milestone
Time tracking
Source branch: bring-scoped-environment-variables-to-core