Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 34,932
    • Issues 34,932
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 1,250
    • Merge Requests 1,250
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #284883

Closed
Open
Opened Nov 18, 2020 by Aishwarya Subramanian@asubramanian1🔵Developer

Support Project variables in include: section of gitlab-ci.yml

Release notes

Problem to solve

Currently, variables cannot be used in the include section of the gitlab-ci.yml.

One of the requirement of group-level compliance pipeline configuration is to be able to use the predefined variable $CI_PROJECT_CONFIG_PATH in the include section. This will be used to make a callback the project pipeline from the group-level compliance pipeline.

This issue proposes the ability to expand pre-defined project variables while evaluating the include section.

Please note this issue addresses part of the issue to support a wider range of variables in the include section.

Intended users

  • Cameron (Compliance Manager)
  • Sidney (Systems Administrator)

Proposal

Expand the project variables in the External::Mapper class before the include section is evaluated.

Technical Implementation

  • Set predefined project variables in the config context
Config::External::Context.new(
  ...
  variables: project&.predefined_variables
)
  • Initialize (project) variables in External::Context
def initialize(project: nil, sha: nil, user: nil, parent_pipeline: nil, variables: [])
  ...
  @variables = variables
  ...
end
  • Update expand_context_attrs to include the variables context (project, file)
def expand_context_attrs
  {
     ...
     variables: context.variables
  }
end
  • Expand variables before include section is evaluated in the mapper:
ExpandVariables.expand(data, @context.variables)

Further details

#30686 (comment 448318651) suggests a rough implementation plan.

Feature flag

variables_in_include_section_ci - defaults to false

Links / references

Demo

include-section-variable-demo

Edited Dec 30, 2020 by Aishwarya Subramanian
Assignee
Assign to
13.8
Milestone
13.8 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: gitlab-org/gitlab#284883