Every Jenkins build creates a network before running the selenoid tests. e.g.,
Creating network "jenkinspr613build11_default"
.
The network name is based on the PR and build number.
The docker-compose.yaml file, had the below config for selenoid service:
selenoid:
image: "aerokube/selenoid:latest-release"
command: -listen :4444 -conf /etc/selenoid/browsers.json -limit 6 -video-output-dir /opt/selenoid/video/ -timeout 3m -container-network jenkinswebpr613build11_default
ports:
- "4444:4444"
How can I configure the value of -container-network
for every build?
Can I pass an environment variable to the yaml file?
I can start the tests locally when I hard-code the value of -container-network
.
As the network name changed with every Jenkins build, I used a different solution:
The value of Network was set to a command line variable ${NETWORK_TAG}
as shown below:
selenoid:
image: "aerokube/selenoid:latest-release"
command: -listen :4444 -conf /etc/selenoid/browsers.json -limit 6 -video-output-dir /opt/selenoid/video/ -timeout 3m -container-network ${NETWORK_TAG}
ports:
- "4444:4444"
The docker-compose up command was run as follows:
NETWORK_TAG=$JENKINS_NETWORK_NAME docker-compose -f docker-compose-selenoid.yml up --build
The value of $JENKINS_NETWORK_NAME
was dynamically set for every Jenkins build.