Passing CI/CD variables to a downstream pipeline leave predefined variables (like $CI_PROJECT_DIR) blank when used within custom variables
Summary
Variables inherited by the child pipeline defined globally in the parent .gitlab-ci.yml
only work if they aren't composed with a predefined variable.
Steps to reproduce
.gitlab-ci.yml
variables:
SOME_CUSTOM_VARIABLE: $CI_PROJECT_DIR/some/path
a-child-pipeline-job:
stage: some_stage
trigger:
include: some-child-ci-config.yml
strategy: depend
when: manual
Actual behavior
Executing export
from the script
step of a job of the child pipeline will show the $CI_PROJECT_DIR
correctly exported, but the $SOME_CUSTOM_VARIABLE
will be /some/path
.
Expected behavior
The $SOME_CUSTOM_VARIABLE
should be evaluated to (value of $CI_PROJECT_DIR)/some/path
instead.
Environment description
GitLab.org with self-hosted runners.
Executor: Docker
docker info
:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 7
Server Version: 18.09.8
Storage Driver: btrfs
Logging Driver: db
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs db fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: dd4f3f40d54250b5172995e0c4facd0261432f75
runc version: 2ae65e2329a7b2562a743d513c95d5bb947eecb5
init version: 142bb85 (expected: fec3683)
Security Options:
apparmor
Kernel Version: 4.4.59+
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.62GiB
Name: Fika_DS918
ID: Z6PM:A2FH:FPRN:LOIO:JZAB:AG2E:P4C6:QXGG:IJDG:LI3V:AZSJ:ILDS
Docker Root Dir: /volume1/@docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No kernel memory limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
config.toml contents
concurrent = 2
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = [hidden]
output_limit = 204800
url = "https://gitlab.com/"
token = [hidden]
executor = "docker"
cache_dir = "/cache"
request_concurrency = 2
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["[hidden]:/cache"]
pull_policy = ["if-not-present"]
shm_size = 0
Used GitLab Runner version
Version: 13.10.0
Git revision: 54944146
Git branch: 13-10-stable
GO version: go1.13.8
Built: 2021-03-21T09:13:32+0000
OS/Arch: linux/amd64
Possible fixes
(Undesirable workaround) Hardcoding the $CI_PROJECT_DIR value in the custom variables used by child pipelines.
Edited by Marc-Antoine Fortier