Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab.com CI shared runner for Android projects

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)?
like image 997
JeB Avatar asked Mar 10 '16 12:03

JeB


People also ask

What is GitLab shared runner?

In GitLab CI, Runners run your yaml. A runner is an isolated (virtual) machine that picks up builds through the coordinator API of GitLab CI. A runner can be specific to a certain project or serve any project in GitLab CI. A runner that serves all projects is called a shared runner.

Does GitLab have Android app?

GitLab SAST now supports mobile applications including iOS apps written in Objective-C and Swift as well as Android apps written in Java and Kotlin powered by the Mobile Security Framework (MobSF).

How do I connect to GitLab runner?

For a shared runner, have an administrator go to the GitLab Admin Area and click Overview > Runners. For a group runner, go to Settings > CI/CD and expand the Runners section. For a project-specific runner, go to Settings > CI/CD and expand the Runners section.


2 Answers

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.

like image 85
Sucipto Avatar answered Oct 28 '22 14:10

Sucipto


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
like image 5
Kai Avatar answered Oct 28 '22 13:10

Kai