Skip to content

Instantly share code, notes, and snippets.

@mugifly
Last active November 24, 2017 11:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mugifly/4712a7e979f02aa4e5383003acadc3ae to your computer and use it in GitHub Desktop.
Save mugifly/4712a7e979f02aa4e5383003acadc3ae to your computer and use it in GitHub Desktop.
Build of Android Studio Project and Post the apk to Slack from Magnum CI

Build of Android Studio Project and Post the apk to Slack from Magnum CI

  • Build the Android Studio Project (Gradle Project) which exist on your Git repository.
  • Upload the generated apk file to Slack.

Basic Setup

  • Name: YOUR-REPOSITORY-NAME
  • Repository URL: git@github.com:XXX/YYY.git
  • Provider: Github
  • Source control: Git
  • Project type: Generic

Build Configuration

Environment variables

You need to describe the settings for build the project as follows.

ANDROID_PACKAGES=tools,build-tools-23.0.2,android-23,extra-android-m2repository,extra-android-support,extra-google-google_play_services,extra-google-m2repository,extra-google-market_apk_expansion,extra-google-market_licensing,extra-google-play_billing
SLACK_TOKEN=YOUR-SLACK-USER-TOKEN
SLACK_CHANNEL=YOUR-SLACK-CHANNEL

Hint: You need to specify the required packages of your app to the ANDROID_PACKAGES variable. You can get the package names using android list sdk --all --extended command.

Build Steps - Dependencies installation:

sudo apt-get install -y openjdk-7-jdk python-software-properties
sudo add-apt-repository -y ppa:cwchien/gradle
sudo apt-get update -y
sudo apt-get install -y gradle-2.10 curl lib32stdc++6 lib32z1
wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar zxf android-sdk_r24.4.1-linux.tgz -C ~/
export ANDROID_HOME=~/android-sdk-linux/
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) |  ~/android-sdk-linux/tools/android update sdk --no-ui --all --filter "${ANDROID_PACKAGES}"
gradle -v
chmod +x gradlew

Build Steps - Test suite commands:

If you want to do testing, please describe it.

Build Steps - After test suite execution:

./gradlew assembleDebug
export apk_name="build-`git rev-parse --short HEAD`.apk"
curl https://slack.com/api/files.upload -F token="${SLACK_TOKEN}" -F channels="${SLACK_CHANNEL}" -F title="${apk_name}" -F filename="${apk_name}" -F file=@app/build/outputs/apk/app-debug.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment