简体   繁体   English

gitlab ci .yml android

[英]gitlab ci .yml android

I'm trying to setup gitlab CI and I can't find any information about error which I'm getting from gitlab runner.我正在尝试设置 gitlab CI,但找不到任何有关从 gitlab runner 获取的错误的信息。 Here is .yml file :这是 .yml 文件:

image: openjdk:8-jdk

variables:
ANDROID_COMPILE_SDK: "28"
ANDROID_BUILD_TOOLS: "28.0.3"
ANDROID_SDK_TOOLS: "28.0.3"

 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-4333796.zip
- unzip -q android-sdk.zip -d android-sdk-linux
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui -- all 
--filter android-${ANDROID_COMPILE_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
- 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/

And finaly error is:最后的错误是:

Processing triggers for libc-bin (2.24-11+deb9u3) ...
$ wget --quiet --output-document=android-sdk.zip 
https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
$ unzip -q android-sdk.zip -d android-sdk-linux
$ echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all 
--filter android-${ANDROID_COMPILE_SDK}
************************************************************************* 
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Unrecognized argument --silent
ERROR: Job failed: exit code 1

What should I do in this case?在这种情况下我该怎么办? Can't find any information about this.找不到有关此的任何信息。 I have tried to change path but won't help.我试图改变路径,但无济于事。

If you want just build your project (with unit tests stage) you can try simple gitlab CI script which i'm using in my project gitlab snippet . 如果您只想构建项目(具有单元测试阶段),则可以尝试在我的gitlab片段中使用的简单gitlab CI脚本。

I'm not sure that this will work with build tools version 28, but you can experiment with this params. 我不确定这是否可以与版本28的构建工具一起使用,但是您可以尝试使用这些参数。

You need to use sdkmanager to setup Android SDK, instead of deprecated "android" command. 您需要使用sdkmanager来设置Android SDK,而不是不推荐使用的“ android”命令。

Here is an example how I setup Android SDK in my Docker file 这是我在Docker文件中设置Android SDK的示例

Try this commands and make sure you changed the compile sdk versions according to your APP, GITLAB CI configuration should be changed when the APP gradle configs changed. 尝试使用此命令,并确保已根据您的APP更改了编译sdk版本。当更改APP gradle配置时,应更改GITLAB CI配置。

image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "26"
  ANDROID_BUILD_TOOLS: "28.0.3"
  ANDROID_SDK_TOOLS:   "4333796"

before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- 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-${ANDROID_SDK_TOOLS}.zip
- unzip -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

cache:
  paths:
  - .gradle/wrapper
  - .gradle/caches
  - android-sdk

stages:
- build

assembleDebug:
  stage: build
  script:
  - ./gradlew assembleDebug
  artifacts:
    paths:
    - app/build/outputs/

I am getting error while running this commands.运行此命令时出现错误。 Using windows and shell executer.使用 windows 和 shell 执行器。 image: openjdk:8-jdk图片:openjdk:8-jdk

variables: ANDROID_COMPILE_SDK: "28" ANDROID_BUILD_TOOLS: "28.0.2" ANDROID_SDK_TOOLS: "4333796"变量: ANDROID_COMPILE_SDK: "28" ANDROID_BUILD_TOOLS: "28.0.2" ANDROID_SDK_TOOLS: "4333796"

before_script: before_script:

  • apt-get --quiet update --yes apt-get --quiet update --yes
  • apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 apt-get --quiet install --yes wget tar 解压 lib32stdc++6 lib32z1
  • wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
  • unzip -d android-sdk-linux android-sdk.zip解压 -d android-sdk-linux android-sdk.zip
  • echo y |回声 y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null android-sdk-linux/tools/bin/sdkmanager“平台;android-${ANDROID_COMPILE_SDK}”>/dev/null
  • echo y |回声 y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null android-sdk-linux/tools/bin/sdkmanager“平台工具”>/dev/null
  • echo y |回声 y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null android-sdk-linux/tools/bin/sdkmanager“构建工具;${ANDROID_BUILD_TOOLS}”>/dev/null
  • export ANDROID_HOME=$PWD/android-sdk-linux导出 ANDROID_HOME=$PWD/android-sdk-linux
  • export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/导出路径=$PATH:$PWD/android-sdk-linux/platform-tools/
  • chmod +x ./gradlew chmod +x ./gradlew

temporarily disable checking for EPIPE error and use yes to accept all licenses暂时禁用检查 EPIPE 错误并使用 yes 接受所有许可证

  • set +o pipefail set +o 管道故障
  • yes |是 | android-sdk-linux/tools/bin/sdkmanager --licenses android-sdk-linux/tools/bin/sdkmanager --licenses
  • set -o pipefail set -o 管道故障

stages:阶段:

  • build建造
  • test测试

lintDebug: stage: build script: - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint lintDebug:阶段:构建脚本:- ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint

assembleDebug: stage: build script: - ./gradlew assembleDebug artifacts: paths: - app/build/outputs/ assembleDebug:阶段:构建脚本:- ./gradlew assembleDebug 工件:路径:- app/build/outputs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM