GitLab.com CI 个项目的共享运行器

GitLab.com CI shared runner for Android projects

我想为我的 Android 应用程序 gradle 项目使用 GitLab CI 系统。项目存储库托管在 GitLab.com,因此我想使用 Gitlab Inc. 提供的共享运行程序之一
虽然官方教程 provides 是 NodeJS 项目运行器配置的示例,也有 Ruby 项目的共享运行器,但我找不到任何示例,甚至找不到支持 Android 应用程序的运行器。

更新

根据这个post你需要设置你自己的跑步者。

您将找到有关在同一 post 上构建 Android 应用程序的更多信息。

这是我在 android 项目中使用的 .gitlab-ci.yml 文件。由于我将其更改为一次安装一个组件,因此它非常稳定。有时许可证无法被接受并且构建失败。但这种情况很少见。 重要的是您的构建工具与此脚本中的相同 (build-tools-23.0.3),也许您必须在此处更改脚本。

您可以省略 artifacts 声明,我用它来获取 lint 报告。

before_script:
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip openjdk-7-jdk lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
  - tar --extract --gzip --file=android-sdk.tgz
  - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-23
  - 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-23.0.3
  - 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
  - wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/gradle-2.12-bin.zip
  - unzip -q gradle.zip
  - export ANDROID_HOME=$PWD/android-sdk-linux

build:
  script:
    - gradle-2.12/bin/gradle assembleDebug check --stacktrace
  artifacts:
    paths:
    - library/build/outputs/lint-results.html
    - app/build/outputs/lint-results.html

我正在使用此 docker 图像 运行 android 在 gitlab-ci

上构建

更新:

移至 Gitlab 注册表

image: registry.gitlab.com/showcheap/android-ci:latest

before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - chmod +x ./gradlew

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

build:
  stage: build
  script:
     - ./gradlew assemble

test:
  stage: test
  script:
     - ./gradlew check

Full Guide可以在这个Gitlab Repository中查看: https://gitlab.com/showcheap/android-ci

如果您的目标 SDK 和构建工具版本未列出,请提出拉取请求或分叉我的存储库,然后创建您的自定义目标和构建版本。