Unable to run selenoid tests with gitlab using dind

194 Views Asked by At

I am relatively new to gitlab and selenoid.

I have been trying to run my tests on selenoid with gitlab and below is what my gitlab-ci.yml file looks like:

image: maven:3.8-openjdk-11

variables:
  MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"

stages:
  - build
  - test

cache:
  paths:
    - .m2/repository

build:
  stage: build
  script:
    - mvn ${MAVEN_OPTS} clean install -DskipTests

test:
  stage: test
  image: docker:latest
  services:
    - name: docker:20.10.16-dind
    - name: aerokube/selenoid:latest-release
      alias: selenoid
    - name: aerokube/selenoid-ui:latest-release
      alias: selenoid-ui
    - name: aerokube/cm:latest-release
      alias: cm
    - name: aerokube/video-recorder:latest-release
      alias: video-recorder
    - name: selenoid/chrome:110.0
  script:
    - docker run -d --name selenoid -v /opt/selenoid/video:/opt/selenoid/video -e OVERRIDE_VIDEO_OUTPUT_DIR=/opt/selenoid/video -e BROWSER_CONFIG_FILE=/opt/selenoid/config/browsers.json aerokube/selenoid:latest-release
    - mvn ${MAVEN_OPTS} clean test -Dcucumber.filter.tags=${FEATURE_TAG} -Dbrowser=chrome -Denv=${ENVIRONMENT}
  artifacts:
    when: always
    name: "report"
    paths:
      - test-output/*
    expire_in: 1 h

I have tried with following combinations before coming up with the above:

  1. not using dind (rest of the things same)
  2. using dind along with passing config from my repo to docker volume using command
  3. creating separate network using network command when spinning up docker
  4. tried not using docker image in the test stage (so that it will use maven image only)

However I have not succeeded with the above.

Lastly , with the above yml; I have tried installing java and maven using apt get but it also didn't work.

And currently with the above yml, I am getting error that mvn command not found.

It would be really helpful if someone can help solve this issue and/or share working example of a selenoid gitlab pipeline with java maven tech stack.

0

There are 0 best solutions below