Skip to content

Instantly share code, notes, and snippets.

@andhikayuana
Last active June 10, 2018 05:24
Show Gist options
  • Save andhikayuana/5d08d24a10c9c18761d8f3071e613024 to your computer and use it in GitHub Desktop.
Save andhikayuana/5d08d24a10c9c18761d8f3071e613024 to your computer and use it in GitHub Desktop.
build android using gitlab ci
# author Yuana
# since june, 20 2018
image: azabost/android-sdk-27:latest
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
stages:
- build
- quality
- package
#### BUILD ####
.build_template: &build_template_def
stage: build
artifacts:
expire_in: 4 hours
paths:
- app/build/outputs/
- .android/
build_debug:
<<: *build_template_def
only:
- develop
script:
- ./gradlew assembleDebug
build_release:
<<: *build_template_def
only:
- master
script:
- ./gradlew assembleRelease
#### QUALITY ####
quality_check:
stage: quality
only:
- master
- develop
script:
- ./gradlew check
artifacts:
name: "reports_${CI_PROJECT_NAME}_${CI_BUILD_REF_NAME}"
when: on_failure
expire_in: 4 days
paths:
- app/build/reports/
#### PACKAGE ####
.package_template: &package_template_def
before_script:
- mkdir -p deliverables
- touch ./deliverables/info.txt
- echo "Build date $(date)" >> ./deliverables/info.txt
- echo "Git branch ${CI_COMMIT_REF_NAME}" >> ./deliverables/info.txt
- echo "Git commit ${CI_COMMIT_SHA}" >> ./deliverables/info.txt
- echo "Gitlab pipeline ${CI_PIPELINE_ID}" >> ./deliverables/info.txt
- export ANDROID_APK_PATH=$PWD/app/build/outputs/apk
package_develop:
<<: *package_template_def
stage: package
environment: Development
only:
- develop
script:
- mv $ANDROID_APK_PATH/debug/output.json ./deliverables/ami-poksay-output-debug.json
- mv $ANDROID_APK_PATH/debug/app-debug*.apk ./deliverables/ami-poksay-$(date)-${CI_COMMIT_SHA}-debug.apk
artifacts:
expire_in: 4 days
paths:
- deliverables
package_release:
<<: *package_template_def
stage: package
environment: Release
only:
- master
script:
- mv $ANDROID_APK_PATH/release/output.json ./deliverables/ami-poksay-output-release.json
- mv $ANDROID_APK_PATH/release/app-release*.apk ./deliverables/ami-poksay-$(date)-${CI_COMMIT_SHA}-release.apk
artifacts:
expire_in: 4 weeks
paths:
- deliverables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment