Skip to content

Instantly share code, notes, and snippets.

@bulwinkel
Last active October 8, 2018 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bulwinkel/b1c371d447df071b90fe6e331d8b7d98 to your computer and use it in GitHub Desktop.
Save bulwinkel/b1c371d447df071b90fe6e331d8b7d98 to your computer and use it in GitHub Desktop.
Hydric AppCenter Scripts: Post to slack for iOS

Hydric AppCenter Scripts for iOS

Currently these scripts post to slack when:

  • a build starts
  • a build finishes successfully

Usage Instructions

  1. Create an incoming webhook for the channel you would like these scripts to post to.
  2. Download and extract all the files from this gist into the root directory of your iOS project.
    If you have 'jq' installed (brew install jq) you can do this step with the following command from the root directory of your project:
    curl --silent "https://gist.github.com/bulwinkel/b1c371d447df071b90fe6e331d8b7d98/archive/$(http https://api.github.com/gists/b1c371d447df071b90fe6e331d8b7d98/commits | jq -r '.[0].version').zip" | tar --strip-components=1 -xf - -C .
  3. Update the Build Specific variables in appcenter-common.sh, most likely you will only need to put in the webhook url for the webook you created earlier.
  4. Setup your appcenter build. Note, if you have already setup an appcenter build for any branches you will need to open the settings then press save for the build to start using the scripts.
#!/usr/bin/env bash
# NOTE: this script should NOT be called in isolation
# Build specific
SLACK_URL="insert full url of incoming webhook"
# iOS Build generic
VERSION=$(git describe --tags)
# Build generic
ICON_EMOJI=":appcenter:" # NOTE: this emoji has been added to slack manually
USERNAME="AppCenter Build"
# USAGE: postToSlack "this will be the message displayed in slack"
function postToSlack() {
curl -X POST --data-urlencode "payload={
\"username\": \"$USERNAME\",
\"text\": \"$1\",
\"icon_emoji\": \"$ICON_EMOJI\"
}" ${SLACK_URL}
}
#!/usr/bin/env bash
# load in the required common vars
. ./appcenter-common.sh
postToSlack "*$APPCENTER_XCODE_SCHEME ($VERSION)* is now available!\nGet it here: https://install.appcenter.ms"
#!/usr/bin/env bash
# load in the required common vars
. ./appcenter-common.sh
postToSlack "Building *$APPCENTER_XCODE_SCHEME ($VERSION)* from branch *$APPCENTER_BRANCH*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment