Skip to content

Instantly share code, notes, and snippets.

@bmbariah
Created November 5, 2019 08:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmbariah/03f70e6f45202699ef63b8572eff0e94 to your computer and use it in GitHub Desktop.
Save bmbariah/03f70e6f45202699ef63b8572eff0e94 to your computer and use it in GitHub Desktop.
Bitbucket Pipeline android upload apk to slack
image: mingc/android-build-box:1.12.0
pipelines:
branches:
master:
- step:
caches:
- gradle
- gradlewrapper
- androidavd
script:
- bash ./gradlew assemble
# FETCH LAST COMMIT MESSAGE
- export LAST_COMMIT_MESSAGE=`git log -1 --pretty=%B`
- export BUILD_DATE=`date "+%Y/%m/%d@%H:%M:%S"`
# CHANNEL_TOKEN - From here: https://api.slack.com/custom-integrations/legacy-tokens
# CHANNEL - Your slack channel name to upload the apk
- mv "./app/build/outputs/apk/debug/app-debug.apk" "./app-${BITBUCKET_BRANCH}-${BITBUCKET_BUILD_NUMBER}.apk"
- curl -F file=@"app-${BITBUCKET_BRANCH}-${BITBUCKET_BUILD_NUMBER}.apk" -F channels=$CHANNEL -F "initial_comment=Pipeline Build on $BUILD_DATE -- $LAST_COMMIT_MESSAGE" -F token=$CHANNEL_TOKEN https://slack.com/api/files.upload
definitions:
caches:
gradlewrapper: ~/.gradle/wrapper
androidavd: $ANDROID_HOME/.android/avd
@bmbariah
Copy link
Author

This allows you to push your latest apk build to a slack channel alongside a message( usually the commit message)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment