Add $CI_PROJECT_CONFIG_PATH as a predefined environment variable
Release notes
Problem to solve
Currently, we cannot use variables in the include:
section of gitlab-ci.yml
. Additionally, there is no variable for the a project's CI configuration path, which could add additional flexibility and strength to GitLab's CI offering by allowing customers to control a "central" pipeline configuration that exists independently from a local project's .gitlab-ci.yml
.
Intended users
Proposal
Following the implementation of #30686 (closed), we should add a new predefined environment variable: $CI_PROJECT_CONFIG_PATH
which would point to a project's local .gitlab-ci.yml
file.
For example:
Project_A
could configure a exteranl.gitlab-ci.yml
file to include:
include: # include the
- file: '$CI_PROJECT_CONFIG_PATH' # .gitlab-ci.yml of
project: '$CI_PROJECT_PATH' # the project currently creating the pipeline
Project_B
could create its own .gitlab-ci.yml
file as usual.
When Project_B
executes its pipeline, it will run the local .gitlab-ci.yml
configuration as well as the instructions contained in external.gitlab-ci.yml
.
Implementation details
- Include
CI_PROJECT_CONFIG_PATH
in the predefined_project_variables method
The value will be the project's ci_config_path_or_default. It contains any overrides mentioned in the custom configuration path, defaulting to .gitlab-ci.yml
if none is provided.
...
.append(key: 'CI_PROJECT_CONFIG_PATH', value: ci_config_path_or_default)
...
- Include documentation changes in https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
- Update existing specs to include the new variable