我需要配置gitlab的CI / CD服务。所以,我创建了一个文件.gitlab-ci.yml
image: openjdk:8-jdk
variables:
ANDROID_COMPILE_SDK: "26"
ANDROID_BUILD_TOOLS: "26.0.2"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/tools_r${ANDROID_SDK_TOOLS}-linux.zip
- unzip android-sdk.zip
- export ANDROID_HOME=$PWD/
- echo y | $ANDROID_HOME/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_COMPILE_SDK}
- echo y | $ANDROID_HOME/tools/android --silent update sdk --no-ui --all --filter platform-tools
- echo y | $ANDROID_HOME/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
- echo y | $ANDROID_HOME/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
- echo y | $ANDROID_HOME/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
- echo y | $ANDROID_HOME/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
- export PATH=$PATH:$ANDROID_HOME
- chmod +x ./gradlew
stages:
- build
build:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
我只需要在没有测试的情况下在云中构建工件。因此,在master提交后,cd管道开始执行,并失败。它一直没能下载sdk:
.....
Preparing to unpack .../libc6-i386_2.24-11+deb9u1_amd64.deb ...
Unpacking libc6-i386 (2.24-11+deb9u1) ...
Selecting previously unselected package lib32z1.
Preparing to unpack .../lib32z1_1%3a1.2.8.dfsg-5_amd64.deb ...
Unpacking lib32z1 (1:1.2.8.dfsg-5) ...
Selecting previously unselected package lib32gcc1.
Preparing to unpack .../lib32gcc1_1%3a6.3.0-18_amd64.deb ...
Unpacking lib32gcc1 (1:6.3.0-18) ...
Selecting previously unselected package lib32stdc++6.
Preparing to unpack .../lib32stdc++6_6.3.0-18_amd64.deb ...
Unpacking lib32stdc++6 (6.3.0-18) ...
Setting up libc6-i386 (2.24-11+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Setting up lib32z1 (1:1.2.8.dfsg-5) ...
Setting up lib32gcc1 (1:6.3.0-18) ...
Setting up lib32stdc++6 (6.3.0-18) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
$ wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/tools_r${ANDROID_SDK_TOOLS}-linux.zip
ERROR: Job failed: exit code 1
答案 0 :(得分:0)
ANDROID_SDK_TOOLS
中没有变量wget
,只有:
ANDROID_BUILD_TOOLS
ANDROID_COMPILE_SDK
答案 1 :(得分:0)
以下配置设置对我有用。似乎Gitlab没有更新默认的.yml文件。更多细节见Link
image: openjdk:8-jdk
cache:
paths:
- .m2/
- .gradle/
variables:
ANDROID_COMPILE_SDK: "26"
ANDROID_BUILD_TOOLS: "26.0.2"
ANDROID_SDK_TOOLS: "26.0.2"
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- unzip -q android-sdk.zip -d android-sdk-linux
- mkdir android-sdk-linux/licenses
- printf "8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e" > android-sdk-linux/licenses/android-sdk-license
- android-sdk-linux/tools/bin/sdkmanager --update > update.log
- android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}" "extras;google;m2repository" "extras;android;m2repository" > installPlatform.log
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew
stages:
- build
- test
build:
stage: build
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
unitTests:
stage: test
script:
- ./gradlew test
答案 2 :(得分:0)
$ android-sdk-linux/tools/bin/sdkmanager --update > update.log
Warning: File /root/.android/repositories.cfg could not be loaded.
$ android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" "build-tools;${ANDROID_BUILD_TOOLS}" "extras;google;m2repository" "extras;android;m2repository" > installPlatform.log
Warning: File /root/.android/repositories.cfg could not be loaded.
$ export ANDROID_HOME=$PWD/android-sdk-linux
$ export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
$ chmod +x ./gradlew
$ ./gradlew assembleDebug
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
错误:作业失败:退出代码1