我是Gitlab CI
的新用户,我试图在.gitlab-ci.yml
文件中使用缓存(在Android
平台上)。 gitlab ci运行良好,但每次我将代码推送到gitlab时,CI都会下载所有数据再次运行它(对于每个运行代码,它将花费大约30分钟)。
我在本教程中使用方法1创建Gitlab CI
:http://www.greysonparrelli.com/post/setting-up-android-builds-in-gitlab-ci-using-shared-runners/
我尝试使用StackOverflow上的许多解决方案,而另一个搜索结果却在Google上但仍然无法缓存。
这是我的.gitlab-ci.yml文件:
image: openjdk:8-jdk
variables:
ANDROID_TARGET_SDK: "24"
ANDROID_BUILD_TOOLS: "24.0.3"
ANDROID_SDK_TOOLS: "24.4.1"
MAVEN_OPTS: -Dmaven.repo.local=/cache/maven.repository
before_script:
- export GRADLE_USER_HOME=/cache/.gradle
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r${ANDROID_SDK_TOOLS}-linux.tgz
- tar --extract --gzip --file=android-sdk.tgz
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_TARGET_SDK}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
- export ANDROID_HOME=$PWD/android-sdk-linux
- chmod +x ./gradlew
cache:
key: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME"
paths:
- .gradle/
- build/
- .m2/
- $HOME/.gradle/caches/
untracked: true
build:
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
我的结果:
Running with gitlab-ci-multi-runner 1.5.2 (76fdacd)
Using Docker executor with image openjdk:8-jdk ...
Pulling docker image openjdk:8-jdk ...
Running on runner-060bf058-project-212-concurrent-0 via gitlab-runner...
Fetching changes...
Removing .gradle/
Removing android-sdk-linux/
Removing android-sdk.tgz
Removing app/build/
Removing build/
HEAD is now at d9b483e text commit here
From my gitlab project here master -> origin/master
Checking out b18798df as master...
Checking cache for build/master...
$ export GRADLE_USER_HOME=/cache/.gradle
$ apt-get --quiet update --yes
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://security.debian.org jessie/updates/main amd64 Packages [402 kB]
Get:4 http://deb.debian.org jessie-backports InRelease [166 kB]
Get:5 http://deb.debian.org jessie Release.gpg [2373 B]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Get:7 http://deb.debian.org jessie Release [148 kB]
Get:8 http://deb.debian.org jessie-backports/main amd64 Packages [959 kB]
Get:9 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 11.0 MB in 22s (485 kB/s)
Reading package lists...
$ apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
Reading package lists...
Building dependency tree...
Reading state information...
unzip is already the newest version.
wget is already the newest version.
Suggested packages:
ncompress tar-scripts
The following NEW packages will be installed:
lib32gcc1 lib32stdc++6 lib32z1 libc6-i386
The following packages will be upgraded:
tar
.....
.....
.....
BUILD SUCCESSFUL
Creating cache build/master...
.gradle/: found 9 matching files
build/: found 4 matching files
WARNING: .m2/: no matching files
WARNING: /root/.gradle/caches/: no matching files
untracked: found 28180 files
Uploading artifacts...
app/build/outputs/: found 7 matching files
Uploading artifacts to coordinator... ok id=643 responseStatus=201 Created token=nGX6FDZD
Build succeeded
我该怎么办?谢谢大家
答案 0 :(得分:0)
var task = Task.Run(() => MyFileSystemWatcher(path));