Backend: Variable expansion in dynamic child pipeline with nested includes
Summary
Variable expansion does not happen in a dynamic child pipeline with nested includes.
Steps to reproduce
- Create a group level CICD variable named
JFROG_ARTIFACTORY_SELECTORand set its value to "test" (group used for this test is namedsuperkas) - Create a project and add a file that will be used to trigger dynamic child pipeline.
Project: superkas/includes-test
File: artifacts/functionbeat_rendered.ci.yml
File content:
include:
- project: 'superkas/gitlab-ci-shared'
ref: main
file:
- 'rwwa-common.ci.yml'
- Add
.gitlab-ci.ymlfile:
stages:
- build_pipelines
- run_pipelines
default:
tags: ["gitlab-gcp-k8s-15-0"]
.build_pipeline_agent_deploy:
stage: build_pipelines
variables:
GIT_STRATEGY: clone
GIT_DEPTH: 1
script:
# Get the templater Scripts & jinja file
- echo "$CI_JOB_NAME"
- cp artifacts/functionbeat_rendered.ci.yml .
artifacts:
paths:
- '*_rendered.ci.yml'
functionbeat_deploy_build:
extends: .build_pipeline_agent_deploy
variables:
ELASTIC_AGENT_NAME: "functionbeat"
functionbeat_child:
stage: run_pipelines
trigger:
strategy: depend
include:
- artifact: functionbeat_rendered.ci.yml
job: functionbeat_deploy_build
variables:
ELASTIC_AGENT_NAME: "functionbeat"
needs:
- job: functionbeat_deploy_build
artifacts: true
- Create the project and the
yamlfile (referenced in theincludekeyword infunctionbeat_rendered.ci.yml):
Project: superkas/gitlab-ci-shared
File: rwwa-common.ci.yml
File content:
include:
- project: 'superkas/gitlab-ci-shared'
ref: main
file:
### JF CLI Support ###
- artifactory-selectors/$JFROG_ARTIFACTORY_SELECTOR.ci.yml
- Create
artifactory-selectors/test.ci.ymlinsuperkas/gitlab-ci-sharedproject:
deploy:
stage: deploy
script:
- echo "$CI_JOB_NAME"
- Run the pipeline. You will get an error. This is because
JFROG_ARTIFACTORY_SELECTORvariable hasn't been expanded.
Found errors in your .gitlab-ci.yml:
• Project 'superkas/gitlab-ci-shared' file "artifactory-selectors/.ci.yml' does not exist!
Example Project
https://gitlab.com/gitlab-gold/emunn-test/kas/nested-includes/-/pipelines/702524602
What is the current bug behavior?
Group level CICD variable, JFROG_ARTIFACTORY_SELECTOR is not available in the nested include file. This makes the following include to fail because file artifactory-selectors/.ci.yml cannot be found:
include:
- project: 'superkas/gitlab-ci-shared'
ref: main
file:
### JF CLI Support ###
- artifactory-selectors/$JFROG_ARTIFACTORY_SELECTOR.ci.yml
What is the expected correct behavior?
artifactory-selectors/$JFROG_ARTIFACTORY_SELECTOR.ci.yml should resolve to artifactory-selectors/test.ci.yml.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)
