Support environment variable substitution in services:[]:alias
Description
I am requesting support for environment variable substitution in the service alias defined in the gitlab ci yaml. For example:
.base-dind-job: &base-dind-job
image: $CI_PROJECT_PATH/build-job:20.10.3
services:
- name: docker:20.10.3-dind
command:
- '--insecure-registry=ci-gitlab-registry-proxy:5000'
- '--insecure-registry=ci-default-registry-proxy:6001'
- '--registry-mirror=http://ci-gitlab-registry-proxy:5000'
- '--registry-mirror=http://ci-default-registry-proxy:6001'
alias: docker_${CI_JOB_ID}
variables:
DOCKER_HOST: tcp://docker_${CI_JOB_ID}:2376
DOCKER_TLS_CERTDIR: "/certs"
ENV: CI
The use case for this is very simple. I am using network_mode
to add all pipeline containers to the same network on the runner host. Because of this all the services will be added to the same network as well. Since one cannot have unique aliases per pipeline+job running multiple instances of the same service with same alias on the same network will cause clients connecting to random ones created across all running jobs. This could be easily prevented if we could add the job id to the alias of the service.
Proposal
Do the same magic as the magic that is done on the service name :). This should be an easy change with a big impact on custom network modes.
Links to related issues and merge requests / references
https://docs.gitlab.com/ee/ci/variables/where_variables_can_be_used.html#gitlab-ciyml-file