Created
November 4, 2019 00:44
-
-
Save orgmir/f7b9bd483f7e15c862a1a51661bb6669 to your computer and use it in GitHub Desktop.
Gitlab CI pipeline setup to build android apps.
This file contains 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: registry.gitlab.com/username/project_name:latest | |
stages: | |
- build | |
before_script: | |
- export GRADLE_USER_HOME=$(pwd)/.gradle | |
- chmod +x ./gradlew | |
cache: | |
key: ${CI_PROJECT_ID} | |
paths: | |
- .gradle/ | |
build: | |
stage: build | |
script: | |
- ./gradlew assembleDebug | |
artifacts: | |
paths: | |
- app/build/outputs/apk/debug/app-debug.apk |
This file contains 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
#!/usr/bin/env bash | |
docker build -t registry.gitlab.com/username/project_name . && docker push registry.gitlab.com/username/project_name |
This file contains 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
FROM openjdk:8-alpine | |
ENV BUILD_TOOLS "29.0.2" | |
ENV SDK_TOOLS_API "29" | |
ENV ANDROID_HOME "/opt/sdk" | |
ENV GLIBC_VERSION "2.27-r0" | |
# Install required dependencies | |
RUN apk add --no-cache --virtual=.build-dependencies wget unzip ca-certificates bash && \ | |
wget https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -O /etc/apk/keys/sgerrand.rsa.pub && \ | |
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk -O /tmp/glibc.apk && \ | |
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk -O /tmp/glibc-bin.apk && \ | |
apk add --no-cache /tmp/glibc.apk /tmp/glibc-bin.apk && \ | |
rm -rf /tmp/* | |
# Download Android SDK tools | |
RUN wget http://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O /tmp/tools.zip && \ | |
mkdir -p ${ANDROID_HOME} && \ | |
unzip /tmp/tools.zip -d ${ANDROID_HOME} && \ | |
rm -v /tmp/tools.zip | |
# Install Android packages & libraries | |
RUN export PATH=$PATH:$ANDROID_HOME/tools/bin && \ | |
mkdir -p /root/.android/ && touch /root/.android/repositories.cfg && \ | |
yes | sdkmanager "--licenses" && \ | |
sdkmanager --verbose "build-tools;${BUILD_TOOLS}" "platform-tools" "platforms;android-${SDK_TOOLS_API}" \ | |
&& sdkmanager --verbose "extras;android;m2repository" "extras;google;google_play_services" "extras;google;m2repository" | |
# Install git | |
RUN apk add --no-cache git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment