Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 44,761
    • Issues 44,761
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,328
    • Merge requests 1,328
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #284883
Closed
Open
Issue created Nov 18, 2020 by Aishwarya Subramanian@aishbuildsContributor

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
Time tracking