2

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.

Deepti K
  • 590
  • 2
  • 9
  • 26

2 Answers2

1

docker-compose builds network name from project name (can be passed explicitly with -p parameter to docker-compose up) and internal name.

To specify internal network, just write it explicitly in docker-compose.yml file and link all services to it like:

docker-compose.yml

version: '3'
services:
  selenoid:
    ...
  networks:
    - my-lovely-net

networks:
  my-lovely-net:

Also, if you don't want to recreate network each time but instead want to reuse global one, you have to first create it like docker network create foo and then tell docker-compose that the network is external:

docker-compose.yml

version: '3'
services:
  selenoid:
    ...
  networks:
    - my-lovely-net

networks:
  my-lovely-net:
    external: true
    name: foo
grapes
  • 8,185
  • 1
  • 19
  • 31
  • A small addition. Selenoid is just a web-service. So nothing special. A generic Docker Compose answer will work. – vania-pooh Jan 11 '19 at 19:17
0

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.

Deepti K
  • 590
  • 2
  • 9
  • 26