I'm new to Gitlab CI
and I'm trying to use cache in .gitlab-ci.yml
file (on Android
platform). The gitlab ci works well but everytime I'm pushing code into gitlab, the CI will download all the data to run it again (It's will take about 30 minutues for each run code pushed).
I'm creating the Gitlab CI
with method 1 in this tutorial : http://www.greysonparrelli.com/post/setting-up-android-builds-in-gitlab-ci-using-shared-runners/
I'm trying with many solutions on StackOverflow and another results on Google but still cannot cache.
Here is my .gitlab-ci.yml file:
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/
And my result:
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
How can I do ? Thank you all