简体   繁体   English

如何在.gitlab-ci.yml中的docker容器中安装卷?

[英]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.

相关问题 如何在Gitlab Runner上将卷挂载到Docker映像? (gitlab-ci.yml) - How to mount a volume to your Docker Image on a Gitlab Runner? (gitlab-ci.yml) GitLab CI:如何连接到 .gitlab-ci.yml 脚本中启动的 docker 容器? - GitLab CI: how to connect to the docker container started in .gitlab-ci.yml script? 构建映像后,如何从.gitlab-ci.yml 运行我的 docker 映像? - How do I run my docker image from .gitlab-ci.yml after building the image? 获取一个 Windows Docker 容器运行与.gitlab-ci.yml - Getting a Windows Docker Container running with .gitlab-ci.yml 使用 gitlab-ci.yml 中的 awk 命令杀死 docker 容器 - Kill a docker container using awk command in gitlab-ci.yml 如何在 gitlab-ci.yml 中将文件从存储库复制到用于作业的 Docker 容器中 - How to copy a file from the repository, into the Docker container used for a job, in gitlab-ci.yml 带有gitlab-ci.yml的Docker内部的Docker - Docker inside docker with gitlab-ci.yml gitlab-ci.yml:如何使用 dind 创建 docker 图像 - gitlab-ci.yml: how to create a docker image using dind .gitlab-ci.yml中的多个Docker镜像 - Multiple Docker images in .gitlab-ci.yml (如何)我可以使用 gitlab-ci.yml 指定要用于服务的非 Docker 集线器映像吗? - (How) can I specify non-Docker hub image to be used for services with gitlab-ci.yml?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM