当使用gitlab ciRunner和sbt时,我想避免每次构建时都下载所有sbt jar文件。有什么办法可以缓存它吗?这是我的.gitlab-ci.yml文件,无法成功缓存.ivy2文件。
image: openjdk:8-jre-alpine
services:
- docker:dind
variables:
SBT_VERSION: "0.13.13"
SBT_HOME: "/usr/local/sbt"
SBT_JAR: "http://dl.bintray.com/sbt/native- packages/sbt/${SBT_VERSION}/sbt-${SBT_VERSION}.tgz"
cache:
paths:
- ~/.ivy2
stages:
- setup
setup:
stage: setup
script:
- export PATH="${SBT_HOME}/bin:$PATH"
- apk --update add bash wget curl tar git
- wget ${SBT_JAR}
- mkdir /usr/local/sbt
- tar -xf sbt-${SBT_VERSION}.tgz -C /usr/local/sbt --strip-components=1
- echo -ne "- with sbt sbt-${SBT_VERSION}\n" >> /root/.built
- rm sbt-${SBT_VERSION}.tgz
- echo "$PATH"
- cat /root/.built
- ls -als /usr/local/sbt
- sbt sbt-version
- ls -als ~/.ivy2
最佳答案
假设您使用的是dockerRunner,则需要更新config.toml
文件并使用卷将/root/.ivy2
持久化
这是我的:
concurrent = 1
check_interval = 0
[[runners]]
name = xxx
url = yyy
token = zzz
executor = "docker"
[runners.docker]
tls_verify = false
image = "ruby:2.1"
privileged = false
disable_cache = false
volumes = ["/cache", "/srv/home:/root/" ]
[runners.cache]