[docker] Expand variables in volume destinations
What does this MR do?
Expand variables in volume destinations
Why was this MR needed?
Variables in volume destinations are expanded, so that the functionality aligns with the one from the kubernetes executor.
What's the best way to test this MR?
-
config.toml
listen_address = ":9252" concurrent = 4 check_interval = 0 connection_max_age = "15m0s" shutdown_timeout = 0 [session_server] session_timeout = 1800 [[runners]] name = "docker-local" url = "https://gitlab.com/" id = 0 token = "glrt-NopeNopeNope" token_obtained_at = 0001-01-01T00:00:00Z token_expires_at = 0001-01-01T00:00:00Z executor = "docker" shell = "bash" environment = [ "COUNTER_DIR=/tmp/foo/bar" ] [runners.docker] tls_verify = false image = "" volumes = ["/${COUNTER_DIR}"] -
.gitlab-ci.yaml
test: image: alpine script: - | set -x counter=0 counterFile="${COUNTER_DIR}/counter" if test -e "${counterFile}" ; then counter="$(cat "${counterFile}")" else echo >&2 "## no counter yet; fresh volume mount" fi counter=$(( counter + 1 )) echo "${counter}" > "${counterFile}" echo >&2 "## wrote new counter ${counter} to ${counterFile}" -
run the pipeline once and see that:
- a new volume is created:
docker volume ls - the counter file cannot be found (new, fresh volume)
- the counter file can be written to
- a new volume is created:
-
run the job again and see that:
- the counter file can be read: the same volume is reused, and because we the counter file is written and read from
${COUNTER_DIR}also shows that the volume mount point is expanded.
- the counter file can be read: the same volume is reused, and because we the counter file is written and read from
What are the relevant issue numbers?
closes: #38249 (closed)
Edited by Hannes Hörl