[英]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. 我在Android项目中使用.gitlab-ci.yml
和.gitlab-ci.yml
作为GitLab CI运行器。 At the end of the test run, gradlew
saves test results in xml and html under the build directory: 在测试运行结束时, gradlew
将测试结果保存在构建目录下的xml和html中:
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/...
. 我想访问这些文件,但是文档没有提到如何安装卷,就像使用docker run -v <path>:/builds/org/...
。
I would advice against mounting volumes from the host for your CI. 我会建议不要从主机为您的CI安装卷。 If you really want to, you have to configure the runner accordingly ( config.toml
). 如果你真的想要,你必须相应地配置运行器( config.toml
)。 If you are using shared
runners you never know on what system a particular build is going to be executed. 如果您使用shared
您永远不知道将在哪个系统上执行特定的构建。
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. 下面你可以找到我用于构建docker-images的我的跑步者的配置( config.toml
)。 You can replace /var/run/docker.sock
by the directory you want your build-results to end up in. 您可以使用希望构建结果最终到达的目录替换/var/run/docker.sock
。
[[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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.