我是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-jdkvariables: ANDROID_TARGET_SDK: "24" ANDROID_BUILD_TOolS: "24.0.3" ANDROID_SDK_TOolS: "24.4.1" MAVEN_OPTS: -Dmaven.repo.local=/cache/maven.repositorybefore_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 ./gradlewcache: key: "$CI_BUILD_name/$CI_BUILD_REF_name" paths: - .gradle/ - build/ - .m2/ - $HOME/.gradle/caches/ untracked: truebuild: 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.tgzRemoving app/build/Removing build/head is Now at d9b483e text commit hereFrom my gitlab project here master -> origin/masterChecking out b18798df as master...Checking cache for build/master...$export GRADLE_USER_HOME=/cache/.gradle$apt-get --quIEt update --yesGet:1 http://security.debian.org jessIE/updates InRelease [63.1 kB]Ign http://deb.debian.org jessIE InReleaseGet: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 lib32z1Reading package Lists...Building dependency tree...Reading state information...unzip is already the newest version.wget is already the newest version.Suggested packages: ncompress tar-scriptsThe following NEW packages will be installed: lib32gcc1 lib32stdc++6 lib32z1 libc6-i386The following packages will be upgraded: tar...............BUILD SUCCESSFulCreating 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=nGX6FDZDBuild succeeded
我能怎么做 ?谢谢你们
解决方法:
# This file is a template, and might need editing before it works on your project.# Read more about this script on this blog post https://about.gitlab.com/2018/10/24/setting-up-gitlab-ci-for-androID-projects/, by Jason Lennyimage: openjdk:8-jdkvariables: ANDROID_COMPILE_SDK: "28" ANDROID_BUILD_TOolS: "28.0.2" ANDROID_SDK_TOolS: "4333796"cache: untracked: false key: ${CI_PROJECT_ID} paths: - androID-sdk-linux - .m2/ - .gradle/ - androID-sdk.zip - /var/cache/apt/ - androID.keystore - keystore.propertIEsstages: - init - test - builddownloadAndroIDSDK: stage: init script: - KS_PASS=$(date +%s | sha256sum | base64 | head -c 32 ; echo) - export GRADLE_USER_HOME=$(pwd)/.gradle - apt-get --quIEt update --yes - apt-get --quIEt install --yes wget tar unzip lib32stdc++6 lib32z1 - wget --quIEt --continue --output-document=androID-sdk.zip https://dl.Google.com/androID/repository/sdk-tools-linux-${ANDROID_SDK_TOolS}.zip - unzip -o -d androID-sdk-linux androID-sdk.zip - echo y | androID-sdk-linux/tools/bin/sdkmanager "platforms;androID-${ANDROID_COMPILE_SDK}" >/dev/null - echo y | androID-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null - echo y | androID-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOolS}" >/dev/null - export ANDROID_HOME=$PWD/androID-sdk-linux - export PATH=$PATH:$PWD/androID-sdk-linux/platform-tools/ - chmod +x ./gradlew # temporarily disable checking for EPIPE error and use yes to accept all licenses - set +o pipefail - yes | androID-sdk-linux/tools/bin/sdkmanager --licenses - set -o pipefail - rm -f $CI_PROJECT_DIR/androID.keystore - echo y | keytool -genkeypair -keyalg RSA -ext KeyUsage:critical=digitalSignature -ext ExtendedkeyUsage:critical=codeSigning -dname "ou=Wdes, c=FR" -alias wdes -keypass $KS_PASS -keystore $CI_PROJECT_DIR/androID.keystore -storepass $KS_PASS -valIDity 1 -deststoretype pkcs12 - keytool -List -storepass $KS_PASS -v -keystore $CI_PROJECT_DIR/androID.keystore - echo -e "release.key.alias=wdes\nrelease.key.password=$KS_PASS\nrelease.storefile=$CI_PROJECT_DIR/androID.keystore\nrelease.password=$KS_PASS\n\ndeBUG.key.alias=wdes\ndeBUG.key.password=$KS_PASS\ndeBUG.storefile=$CI_PROJECT_DIR/androID.keystore\ndeBUG.password=$KS_PASS\n" > keystore.propertIEsassembleDeBUG: stage: build dependencIEs: [ 'downloadAndroIDSDK' ] script: - export GRADLE_USER_HOME=$(pwd)/.gradle - export ANDROID_HOME=$PWD/androID-sdk-linux - export PATH=$PATH:$PWD/androID-sdk-linux/platform-tools/ - chmod +x ./gradlew - ./gradlew assembleDeBUG artifacts: paths: - app/build/outputs/assembleRelease: stage: build dependencIEs: [ 'downloadAndroIDSDK' ] script: - export GRADLE_USER_HOME=$(pwd)/.gradle - export ANDROID_HOME=$PWD/androID-sdk-linux - export PATH=$PATH:$PWD/androID-sdk-linux/platform-tools/ - chmod +x ./gradlew - ./gradlew assembleRelease artifacts: paths: - app/build/outputs/lintDeBUG: stage: test dependencIEs: [ 'downloadAndroIDSDK' ] script: - export GRADLE_USER_HOME=$(pwd)/.gradle - export ANDROID_HOME=$PWD/androID-sdk-linux - export PATH=$PATH:$PWD/androID-sdk-linux/platform-tools/ - chmod +x ./gradlew - ./gradlew -Pci --console=plain :app:lintDeBUG -PbuildDir=lintlintfiles: stage: test dependencIEs: [ 'downloadAndroIDSDK' ] script: - export GRADLE_USER_HOME=$(pwd)/.gradle - export ANDROID_HOME=$PWD/androID-sdk-linux - export PATH=$PATH:$PWD/androID-sdk-linux/platform-tools/ - chmod +x ./gradlew - ./gradlew @R_323_5404@deBUGTests: stage: test dependencIEs: [ 'downloadAndroIDSDK' ] script: - export GRADLE_USER_HOME=$(pwd)/.gradle - export ANDROID_HOME=$PWD/androID-sdk-linux - export PATH=$PATH:$PWD/androID-sdk-linux/platform-tools/ - chmod +x ./gradlew - ./gradlew -Pci --console=plain :app:testDeBUG
总结 以上是内存溢出为你收集整理的android – 缓存.gitlab-ci.yml文件中的所有数据全部内容,希望文章能够帮你解决android – 缓存.gitlab-ci.yml文件中的所有数据所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)