使用Gitlab CI生成Android构建

are*_*986 22 android gitlab-ci

我刚刚安装了Gitlab作为我的项目的存储库,我想利用他们的Gitlab CI系统.我希望在每次提交后自动生成分发并调试Apk.我用Google搜索,但我没有找到任何教程或类似案例.如果有人能以某种方式指导我,那就太好了.

谢谢!

Gre*_*lli 13

我刚刚写了一篇关于如何使用共享运行器在Gitlab CI中设置Android构建的博客文章.

最快的方法是.gitlab-ci.yml使用以下内容:

image: openjdk:8-jdk

variables:
  ANDROID_TARGET_SDK: "24"
  ANDROID_BUILD_TOOLS: "24.0.0"
  ANDROID_SDK_TOOLS: "24.4.1"

before_script:
  - 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

build:
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
    - app/build/outputs/
Run Code Online (Sandbox Code Playgroud)

这将从使用Java 8 Docker映像开始,然后在构建运行之前继续下载并安装必要的Android SDK.我的帖子还详细介绍了如何将其构建为Docker镜像并将其托管在Gitlab本身上.

希望这有帮助!

更新 - 4/10/2017

我在16年11月为官方Gitlab博客写了关于在Gitlab CI中设置Android版本的规范博客文章.包括有关如何运行测试等的详细信息.链接在这里.

https://about.gitlab.com/2016/11/30/setting-up-gitlab-ci-for-android-projects/