I am having the next .gitlab-ci.yml file in which I am trying to use the Redis image as a service, create a container from it and then execute the unit tests of my application. The Redis image is already being registered into my GitLab runner.
stages:
- test
before_script:
- export several environment variables and configurations needed
cache:
paths:
- .gradle/caches
build-job:
stage: test
script:
- echo "Building...."
- gradle build -x test --info $GRADLE_PARAMETERS
- echo "END of Build...."
artifacts:
paths:
- build/libs/*
expire_in: 1 day
unit-tests-job:
stage: test
services:
- redis:7.2.1
variables:
REDIS_PORT: 6379
REDIS_HOST: redis
REDIS_URL: redis://redis:6379/0
script:
- echo "Starting execution of unit tests...."
- gradle libertyStart --info $GRADLE_PARAMETERS
- sleep 30
- gradle test --info $GRADLE_PARAMETERS
- echo "Execution of unit tests finished...."
However, after the commiting and pushing into GitLab repo I am receiving the following stack trace from my pipeline:
ERROR: Job failed (system failure): prepare environment: Error response from daemon: bad parameter: link is not supported (docker.go:659:0s). Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
From my research I found that the --link
flag is being deprecated. I tried to use user-defined networks as recommended by Docker but I am still receiving the same error. I changed the .gitlab-ci.yml by moving services and alias at the top level. The alias provides a hostname for the Redis container within the user-defined network.
services:
- name: redis:latest
alias: redis
variables:
REDIS_PORT: 6379
REDIS_HOST: redis
REDIS_URL: redis://redis:6379/0
Unfortunately I don't have access to the config.toml file of my GitLab runner, as of now.
Is something I am doing wrong or it has something to do with the runner? What am I missing?
This is because your runner host is not configured correctly. This problem can't be reproduced on gitlab.com shared runners, for example.
Unfortunately I don't have access to the config.toml file of my GitLab runner
You will need to provide details about your runner and have access to the runner server and configuration to be able to identify and fix this issue.
Without being able to see the configuration, my assessment is that this issue is probably because your runner is configured to use podman, but as noted in the GitLab podman configuration docs links are not supported with podman.
To run services with Podman as an executor, enable the
FF_NETWORK_PER_BUILD
feature flag. Docker container links are legacy and are not supported by Podman. For services that create a network alias, you must install thepodman-plugins
package.
If this hunch is correct, you should be able to fix this by enabling the FF_NETWORK_PER_BUILD
feature flag (which, ideally, should have been set in your runner configuration if this is the case) in your job:
variables:
FF_NETWORK_PER_BUILD: 1
If this does not work, it might be because your runner host is missing the podman-plugins
package.