0

I would like to run the integration tests of a project furnished by a client. Said client provided me a list of tests and a Docker container (they didn't give me the Dockerfile though). I wanted to configure a GitLab runner to mount this Docker image but the image needs input parameters to be run, e.g.:

docker run --rm -it -u username -v $SCRIPT_DIR:/tests-folder $HOSTS $DOCKER_IMAGE

What it's doing is that it runs Docker in an interactive mode, mapping the current directory to the Docker image and specifies a host (against which the tests are performed).

However, to my knowledge it is not possible to configure a Docker GitLab runner to run with input parameters with the gitlab-runner register command (those options should rather be in the Dockerfile as the ENTRYPOINT or CMD).

What I've tried so far is to register a Shell GitLab runner on the machine where the tests are hosted, run the Docker from within the .gitlab-ci.yml file, and then launch the tests.

stages:
  - test

integration-tests:
  stage: test
  tags:
    - host-vm-shell
  script:
    - docker run --rm -it -u username -v $SCRIPT_DIR:/tests-folder $HOSTS $DOCKER_IMAGE
    - robot test-1.robot 

But when I do this, it launches the Docker image and immediately exits it, so when I try to run the tests, I'm back in the shell of the host VM.

Is there a way for me to launch this Docker container from within a Shell GitLab runner and launch my tests from within the container?

avazula
  • 472
  • 1
  • 6
  • 23
  • What is the `ENTRYPOINT` and `CMD` of your `$DOCKER_IMAGE`? You can look this up by running `docker inspect $DOCKER_IMAGE`. By the way, you can reconstruct the Dockerfile, see [this thread](https://stackoverflow.com/questions/55954188/if-i-have-locally-docker-image-how-could-i-list-what-is-installed-on-it/55954287#55954287) and linked sites. – bellackn May 20 '19 at 08:39
  • Also, why do you have to put `-it` there? This is probably the main reason for the GitLab Runner not working as expected, as it probably cannot attach a tty. – bellackn May 20 '19 at 08:44
  • @bellackn I actually fixed this when running in GitLab, it's just that I wanted to provide the command that my client gave me. – avazula May 20 '19 at 09:55

0 Answers0