Created
April 17, 2019 11:26
-
-
Save JGeraldoLima/19d02275dd74cdc723fb8dadae823384 to your computer and use it in GitHub Desktop.
Android .gitlab-ci.yml Gitlab CI/CD example file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: openjdk:8-jdk | |
variables: | |
ANDROID_COMPILE_SDK: "28" | |
ANDROID_BUILD_TOOLS: "29.0.0-rc2" | |
ANDROID_SDK_TOOLS: "26.1.1" # only to register, because since some version, the link to download does not follow a pattern with the desired SDK version | |
APP_NAME: "MyProject" | |
before_script: | |
- apt-get --quiet update --yes | |
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 | |
- wget --output-document=android-sdk.tgz https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip | |
- mkdir android-sdk-linux && unzip android-sdk.tgz -d android-sdk-linux | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "platform-tools" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "tools" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "extras;android;m2repository" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "extras;google;google_play_services" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "extras;google;m2repository" | |
- echo y | ./android-sdk-linux/tools/bin/sdkmanager "ndk-bundle" | |
- export ANDROID_HOME=$PWD/android-sdk-linux | |
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/ | |
- chmod +x ./gradlew | |
stages: | |
- build | |
- lint | |
- test | |
- package | |
.build_template: &build | |
stage: build | |
artifacts: | |
expire_in: 8 hours | |
paths: | |
- app/build/outputs/ | |
build:release: | |
<<: *build | |
script: | |
- ./gradlew assembleRelease -PversionCode=$VERSION_CODE -PversionName=$VERSION_NAME | |
lint: | |
stage: lint | |
script: | |
- ./gradlew lint | |
######################################################################## | |
# TESTS | |
.test_template: &test | |
stage: test | |
only: | |
- master | |
test:unit: | |
<<: *test | |
script: | |
- ./gradlew test | |
# TODO: add functional (Espresso) tests config in the future | |
######################################################################## | |
# PACKAGE | |
.package_template: &package | |
before_script: | |
- mkdir -p exported | |
# TODO: explicit package:release:unsigned and package:release:signed in the future | |
package:release: | |
<<: *package | |
stage: package | |
environment: Release | |
script: | |
- mv app/build/outputs/apk/release/app-release.apk ./exported/${APP_NAME}-$VERSION_NAME-release.apk | |
dependencies: | |
- build:release | |
artifacts: | |
paths: | |
- exported |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to this tutorial https://medium.com/@NickKaramoff/gitlab-ci-setup-for-an-android-app-3ba57b369b5f