我在Java上有项目,在这里进行测试。现在我有了.gitlab-ci.yml
:
image: maven:latest
stages:
- build
build:
stage: build
script:
- mvn test-compile compile
tags:
- mytag
only:
refs:
- dev
每次,当我在回购中提交承诺时,我都在等待很多时间,它会下载所有依赖项。在泊坞窗中,我们可以使用音量选项。问题:
我可以在本地下载和编译此项目以创建.m2
目录,也可以在我的.gitlab-ci.yml
中使用此目录。如果是的话,您能帮我吗,因为我还没有找到相应的互联网示例。
我在/etc/gitlab-runner/config.toml
中进行了更改:
[runners.docker]
tls_verify = false
image = "maven:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache","/M2/.m2:/root/.m2"]
shm_size = 0
/M2/
是一个目录,具有gitlab-runner所有者。但这无济于事,我们怎么看:
Downloaded from central: https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-parent/1.3/hamcrest-parent-1.3.pom (2.0 kB at 20 kB/s)
Downloading from atlas: https://dl.bintray.com/qameta/maven/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
Downloading from nio: http://clojars.org/repo/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/seleniumhq/selenium/selenium-java/3.8.1/selenium-java-3.8.1.pom
Progress (1): 2.2/5.9 kB
Progress (1): 5.0/5.9 kB
Progress (1): 5.9 kB
答案 0 :(得分:2)
采取的步骤: (主机-机器gitlab-安装了转轮,并签署了转轮)
volumes = [“ / cache”,“〜/ .m2:/root/.m2”]
cache: paths: - /root/.m2/
variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2"
.gilatb.yml应该看起来像这样
答案 1 :(得分:0)
FROM maven:3.6.1-jdk-8-alpine COPY pom.xml . RUN mvn verify clean --fail-never
docker build -t xxx / projectName:base。
现在“基本docker映像”已缓存了数据。
然后您可以在gitlab-ci.yml中使用“基础docker映像”:
image: xxx/projectName:base stages: - build build: stage: build script: - mvn test-compile compile tags: - mytag only: refs: - dev