Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I mount a volume in a docker container in .gitlab-ci.yml?

I'm using .gitlab-ci.yml and docker as a GitLab CI runner on an Android project. At the end of the test run, gradlew saves test results in xml and html under the build directory:

Finished generating test XML results (0.001 secs) into: /builds/org/project/sdk/build/test-results/release
 Generating HTML test report...
Finished generating test html results (0.002 secs) into: /builds/org/project/sdk/build/reports/tests/release

I'd like to have access to these files, but the documentation doesn't mention how to mount a volume like one would with docker run -v <path>:/builds/org/....

like image 553
Travis Holton Avatar asked Aug 17 '16 19:08

Travis Holton


1 Answers

I would advice against mounting volumes from the host for your CI. If you really want to, you have to configure the runner accordingly (config.toml). If you are using shared runners you never know on what system a particular build is going to be executed.

I think the better solution would be to define the test-results as artifacts.

That way, the test-results are available for older builds and not only the latest build.

Below you can find the configuration (config.toml) of my runner I use for building docker-images. You can replace /var/run/docker.sock by the directory you want your build-results to end up in.

[[runners]]
  name = "Docker"
  url = "https://mygitlab/ci"
  token = "mytoken"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    privileged = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
  [runners.cache]
    Insecure = false
like image 73
Martin Avatar answered Oct 16 '22 01:10

Martin