GitLab.com CI shared runner for Android projects

2019-03-18 03:28发布

I'd like to use GitLab CI system for my Android application gradle project. The project repository is hosted on GitLab.com, so I'd like to use one of the Shared Runners provided by Gitlab Inc.
While the official tutorial provides an example for NodeJS project runner configuration and there are also shared runners for Ruby projects, I couldn't find any example or even a runner that supports Android applications.

  • Is there a shared runner provided by GitLab.com, which supports Android projects out of the box (by specifying image: android:4.2.2 or something like this)?
  • Is there a way to configure existing shared runner provided by GitLab.com to support Android projects (by modifying the .gitlab-ci.yml file)?

3条回答
老娘就宠你
2楼-- · 2019-03-18 03:57

This is the .gitlab-ci.yml file which I'm using in my android project. Since I changed it to install one component at a time it is pretty stable. Sometimes the licence can't be accepted and the build fails. But that's a rare case. It is important that your build-tools are the same as in this script (build-tools-23.0.3) maybe you have to change the script here.

You can leave out the artifacts declaration I use it to get the lint report.

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
查看更多
淡お忘
3楼-- · 2019-03-18 04:16

UPDATE

According to this post you'll need to set up your own runner.

You'll find more information regarding building Android Apps on the same post.

查看更多
够拽才男人
4楼-- · 2019-03-18 04:21

I'm using this docker image to run android build on gitlab-ci

Update:

Moved to Gitlab registry

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 can check in this Gitlab Repository: https://gitlab.com/showcheap/android-ci

If your Target SDK and Build Tools version are not listed, please make a pull request or fork my repo then make your custom target and build version.

查看更多
登录 后发表回答