15

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/....

Travis Holton
  • 185
  • 1
  • 1
  • 5

1 Answers1

20

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
Martin
  • 2,754
  • 1
  • 15
  • 35
  • I realised after reading the gitlab-ci.yml documentation a little more carefully that I was on the wrong path. Using _artifacts_ as suggested by @mgansler worked for me. – Travis Holton Aug 31 '16 at 09:37
  • @Martin I installed my gitlab-runner on k8s using the Gitlab 11.9.8 - through the K8s integration UI. Now after installation, I can't seem to modify the configuration of the runner. I used kubeadm to set up my k8s cluster. I want to mount /var/run/docker.sock from the host to the container where i'm building my code. – Tjs Apr 22 '19 at 21:11
  • an example of how artifacts can be used to access a file generated during gitlab pipeline execution, even if the pipeline fails: https://juristr.com/blog/2020/10/upload-failed-artifacts-gitlab/ – oomer May 18 '21 at 08:23