├── LICENSE ├── README.md ├── update_version.sh └── upload.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jeremy Fox 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | iOS Build Scripts for Xcode Bots 2 | ================= 3 | 4 | Build scripts that can be used to update build #, upload binary to HockeyApp, and post notifications into HipChat from an Xcode Bot. 5 | 6 | How to use these scripts 7 | ======================== 8 | 9 | First, if you are not familiar with creating Xcode Bots, please do some research on this topic first as these scripts are only designed to be used with Xcode Bots. 10 | 11 | The first step is to create your Bot. After you've done this follow the instructions below to setup both scipts. 12 | 13 | Setting up update_version.sh 14 | ---------------------------- 15 | 1. On your Xcode Server machine, cd into the `/Library/Developer/XcodeServer/` director and create a new folder called `Config`. 16 | 2. Inside of the newly created `Config` folder create a new folder for each of the build configurations that you'll be using with Xcode Bots. For example, if you have an Ad Hoc and/or an Enterprise configuration in your project that you'll be using for builds make sure you create a folder with this configurations name.A 17 | 3. For each configuration directory you created, within the directory, create a new plist file that that is named just like your projects Info.plist. For example, if the name of your project is MyAwesomeApp then your Info.list file would be named `MyAwesomeApp-Info.plist`.B You'll need to add only one `dict` within the Info.plist that will have one KVP. The key will be `CFBundleVersion` and the value will be `0`.C 18 | 4. Now that you've got all of the proper directories and plist files in place, you are ready to add the `update_version.sh` script to your project. To do this, open your project and create a new `Target` > `External Build System`. You can name this Target what ever you want, I typically use `Update Build Version`. After the new Target has been created, select the `Info` tab and input the following values. Please note, this assumes you've placed the `update_version.sh` script in the root directory of you project. If not, you'll need to use to actual path in which you placed the script in your project. 19 | - Build Tool: /bin/sh 20 | - Arguments: $PROJECT_DIR/update_version.sh 21 | - Directory: $PROJECT_DIR/ 22 | 5. From the scheme selection drop down, select the scheme that you'll be building in your Xcode Bot, then choose `Edit Scheme...`. Select `Build` and click the + to add a new Target. Choose the Target you created in step 4. Make sure you move it to the very top of the list of Targets and unselect everything except `Archive`.D 23 | 6. You have finished setting up the `update_version.sh` script. 24 | 25 | A 26 | 27 | ![Configs](http://note.io/1J8HOuu) 28 | 29 | B 30 | 31 | ![Configs-Ad-Hoc](http://note.io/1Gv3Wx4) 32 | 33 | C 34 | 35 | ```xml 36 | 37 | 38 | 39 | 40 | CFBundleVersion 41 | 0 42 | 43 | 44 | ``` 45 | 46 | D 47 | 48 | ![Configs-Ad-Hoc](http://note.io/1Gv6A63) 49 | 50 | Setting up upload.sh 51 | ==================== 52 | 53 | 1. In the last screen of the new Xcode Bot creation/update menu you'll have the oppertunity to add Before and After Integration Run Scripts. The first step will be to create a `Before Integration` Run Script that will be used to configure git so that it can send tags to your github repository during each build. 54 | 2. The first thing you'll need to do is get a `Peronal Access Token` so that the Bot can push tags back to your repo. To do this open https://github.com/settings/applications and click on `Generate new token`. Unselect everything except either `repo` if your repository is private or `public_repo` if your repository is public. Copy your new personal access token and enter it in the git configuration code that is reference in the next step. 55 | 3. From the last screen of the Xcode Bot creation/update menu click the `+ Add Trigger` button in the `Before Integration` section. When the new Run Script box appears, enter the lines from the example in E below and replace everything inside of a `<...>` tag with your appriopriate information. 56 | 4. Now scroll down to the `After Integration` section and click the `+ Add Trigger` and enter in the lines from example F. Make sure to update all information in these lines accordingly. Please note, this assumes you've placed the `upload.sh` script in the root directory of your project. If not, you'll need to update it accordingly. 57 | 5. As long as you've properly configured everything you should now be ready to start an integration and see that your build # has incremeneted, you got a build in TestFlight, and if have HipChat and configured the settings for HipChap received a build notificaion within the HipChat room of your choosing. 58 | 59 | E 60 | 61 | ``` 62 | cd "$XCS_SOURCE_DIR/" 63 | git config user.email "ci@buildbox.com" 64 | git config user.name "Build Box" 65 | git config remote.origin.url "https://@github.com//.git" 66 | git config -l 67 | ``` 68 | 69 | F 70 | 71 | ``` 72 | PRODUCT_NAME="MyAwesomeApp" 73 | SRCROOT_MAIN_DIR="my_awesome_app" 74 | GITHUB_ACCOUNT="atljeremy" 75 | DISTRO_LIST="" 76 | HOCKEYAPP_API_TOKEN="" 77 | SIGNING_IDENTITY="iPhone Distribution: Jeremy Fox" 78 | PROVISIONING_PROFILE="52bf378s-ea37-738e-djs9-shdisdisciod8ju" 79 | 80 | # Posting to HipChat is supported, if you have a HipChat room that you would like build notifications sent into, uncomment the lines below and enter in your appropriate info 81 | # HIPCHAT_ROOM_NAME="MyAwesomeApp Room" 82 | # HIP_CHAT_AUTH_TOKEN="hsishid8ew8yei8yifyri8ysyi" 83 | 84 | source "$XCS_SOURCE_DIR/$SRCROOT_MAIN_DIR/upload.sh" 85 | ``` 86 | -------------------------------------------------------------------------------- /update_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # (Above line comes out when placing in Xcode scheme) 4 | # 5 | 6 | ############################################################################ 7 | # Configurable Options 8 | ############################################################################ 9 | 10 | ############################################################################ 11 | # Used to tell the build system where to find the local tracking copying of 12 | # the projects info.plist file which is used to keep track of the build #. 13 | # 14 | # Set this ENV variable before calling this script or default value will be used. 15 | TRACKING_PLIST_PATH=${TRACKING_PLIST_PATH:="/Library/Developer/XcodeServer/Config/$CONFIGURATION"} 16 | 17 | ############################################################################ 18 | # Used to tell the build system where to find the projects info.plist file 19 | # 20 | # Set this ENV variable before calling this script or default value will be used. 21 | PROJ_PLIST=${PROJ_PLIST:="${XCS_SOURCE_DIR}/${PROJECT_NAME}/${PROJECT_NAME}-Info.plist"} 22 | 23 | ############################################################################ 24 | # Used to tell the build system if it should upload the new version to source sontrol 25 | # 26 | # Set this ENV variable before calling this script or default value will be used. 27 | COMMIT_VERSION=${COMMIT_VERSION:=0} 28 | 29 | ############################################################################ 30 | # DO NOT CHANGE ANYTHING BELOW THIS LINE 31 | ############################################################################ 32 | 33 | echo "Bumping build number..." 34 | echo "PROJECT PLIST FILE: $PROJ_PLIST" 35 | PLIST="$TRACKING_PLIST_PATH/${PROJECT_NAME}-Info.plist" 36 | echo "PLIST FILE: $PLIST" 37 | 38 | # increment the build number 39 | BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PLIST}") 40 | if [[ "${BUNDLE_VERSION}" == "" ]]; then 41 | echo "No build number in $plist" 42 | exit 2 43 | fi 44 | 45 | IFS='.' read -a BUNDLE_PARTS <<< "$BUNDLE_VERSION" 46 | LAST_PART_INDEX=$(expr ${#BUNDLE_PARTS[@]} - 1) 47 | LAST_PART=$(expr ${BUNDLE_PARTS[$LAST_PART_INDEX]} + 1) 48 | BUNDLE_PARTS[$LAST_PART_INDEX]=$LAST_PART 49 | 50 | function join { local IFS="$1"; shift; echo "$*"; } 51 | NEW_BUNDLE_VERSION=$(join . ${BUNDLE_PARTS[@]}) 52 | 53 | /usr/libexec/Plistbuddy -c "Set CFBundleVersion $NEW_BUNDLE_VERSION" "${PLIST}" 54 | /usr/libexec/Plistbuddy -c "Set CFBundleVersion $NEW_BUNDLE_VERSION" "${PROJ_PLIST}" 55 | 56 | if [ $COMMIT_VERSION -eq 1 ]; then 57 | CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) 58 | echo "Committing the build number to branch: $CURRENT_BRANCH" 59 | cd ${PROJECT_DIR}; git add $PLIST 60 | cd ${PROJECT_DIR}; git commit -m "Bumped the build number to $NEW_BUNDLE_VERSION" 61 | cd ${PROJECT_DIR}; git push -u origin $CURRENT_BRANCH 62 | echo "Build number committed." 63 | else 64 | echo "Not committing build number." 65 | echo "To commit new build numbers set COMMIT_VERSION=1." 66 | fi 67 | 68 | echo "Bumped build number to $NEW_BUNDLE_VERSION" 69 | -------------------------------------------------------------------------------- /upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # (Above line comes out when placing in Xcode scheme) 4 | # 5 | 6 | ############################################################################ 7 | # Example of usage in Xcode Bot 8 | ############################################################################ 9 | # This script was designed to be run from a post integration step of an Xcode 10 | # Bot. Here is an example of how to do this. 11 | # 12 | # PRODUCT_NAME="MyAwesomeApp" 13 | # SRCROOT_MAIN_DIR="my_awesome_app" 14 | # HIPCHAT_ROOM_NAME="MyAwesomeApp Room" 15 | # HIP_CHAT_AUTH_TOKEN="hsishid8ew8yei8yifyri8ysyi" 16 | # GITHUB_ACCOUNT="atljeremy" 17 | # DISTRO_LIST="MyAwesomeApp TestFlight Distro List Name" 18 | # HOCKEYAPP_API_TOKEN="kahsdiuHISUhdsi8sd9oshjh_hskdihsaskdiao98asydhaisuhISL" 19 | # SIGNING_IDENTITY="iPhone Distribution: Jeremy Fox" 20 | # PROVISIONING_PROFILE="52bf378s-ea37-738e-djs9-shdisdisciod8ju" 21 | # 22 | # source "$XCS_SOURCE_DIR/$SRCROOT_MAIN_DIR/upload.sh" 23 | 24 | ############################################################################ 25 | # Configurable Options 26 | ############################################################################ 27 | 28 | ############################################################################ 29 | # Used to tell the build system if a build should fail if the upload process fails 30 | # 31 | # Set this ENV variable before calling this script or the default value will be used. 32 | REQUIRE_UPLOAD_SUCCESS=${REQUIRE_UPLOAD_SUCCESS:=1} 33 | 34 | ############################################################################ 35 | # Used to tell the build system which HipChat Room should receive build notifications 36 | # 37 | # Set this ENV variable before calling this script or the default value will be used. 38 | HIPCHAT_ROOM_NAME=${HIPCHAT_ROOM_NAME:="NOT_DEFINED"} 39 | 40 | ############################################################################ 41 | # Used to tell this script to notify the HipChat room specified in 42 | # HIPCHAT_ROOM_NAME variable. If NOTIFY_HIPCHAT_ROOM is set to 1 (true) and 43 | # HIPCHAT_ROOM_NAME is not set, the build will fail. 44 | # 45 | # Set this ENV variable before calling this script or the default value will be used. 46 | NOTIFY_HIPCHAT_ROOM=${NOTIFY_HIPCHAT_ROOM:=1} 47 | 48 | ############################################################################ 49 | # Used to tell this script to notify Slack based on the Slack incoming web 50 | # service URL specified in the SLACK_INCOMING_WEBSERVICE_URL. 51 | # 52 | # Set this ENV variable before calling this script or the default value will be used. 53 | NOTIFY_SLACK_ROOM=${NOTIFY_SLACK_ROOM:=1} 54 | 55 | ############################################################################ 56 | # Used to tell this script what Slack incoming web service URL to use for 57 | # sending messages into Slack. 58 | # 59 | # Set this ENV variable before calling this script or the default value will be used. 60 | SLACK_INCOMING_WEBSERVICE_URL=${SLACK_INCOMING_WEBSERVICE_URL:="NOT_DEFINED"} 61 | 62 | ############################################################################ 63 | # Used to tell the build system if members of the HIPCHAT_ROOM_NAME should receive 64 | # a notification when the build system posts a build notificaiton 65 | # 66 | # Set this ENV variable before calling this script or the default value will be used. 67 | POST_NOTIFY=${POST_NOTIFY:=true} 68 | 69 | ############################################################################ 70 | # Used to tell the build system what HipChat Auth Token should be used for requests 71 | # to the HipChat API 72 | # 73 | # Set this ENV variable before calling this script or the default value will be used. 74 | HIP_CHAT_AUTH_TOKEN=${HIP_CHAT_AUTH_TOKEN:="NOT_DEFINED"} 75 | 76 | ############################################################################ 77 | # Used to specify the source control main directory 78 | # 79 | # Set this ENV variable before calling this script. 80 | SRCROOT_MAIN_DIR=${SRCROOT_MAIN_DIR:="$PRODUCT_NAME"} 81 | 82 | ############################################################################ 83 | # Used to specify the Github account in which tags should be sent 84 | # 85 | # Set this ENV variable before calling this script or the default value will be used. 86 | GITHUB_ACCOUNT=${GITHUB_ACCOUNT:="NOT_DEFINED"} 87 | 88 | ############################################################################ 89 | # Set the Enterprise App Store Project ID that these builds should be uploaded to 90 | # This defaults to project ID 24 if not set, which is the "AG Testing" project. 91 | # 92 | # Set this ENV variable before calling this script or the default value will be used. 93 | DISTRO_LIST=${DISTRO_LIST:="All"} 94 | 95 | ############################################################################ 96 | # HockeyApp api token to be used for upload request 97 | # 98 | # Set this ENV variable before calling this script or the default value will be used. 99 | HOCKEYAPP_API_TOKEN=${HOCKEYAPP_API_TOKEN:=""} 100 | 101 | ############################################################################ 102 | # Crashlytics api token to be used for upload request 103 | # 104 | # Set this ENV variable before calling this script or the default value will be used. 105 | CRASHLYTICS_API_TOKEN=${CRASHLYTICS_API_TOKEN:=""} 106 | 107 | ############################################################################ 108 | # Crashlytics build secret to be used for upload request 109 | # 110 | # Set this ENV variable before calling this script or the default value will be used. 111 | CRASHLYTICS_BUILD_SECRET=${CRASHLYTICS_BUILD_SECRET:=""} 112 | 113 | ############################################################################ 114 | # Crashlytics emails to be used for upload request 115 | # 116 | # Set this ENV variable before calling this script or the default value will be used. 117 | CRASHLYTICS_EMAILS=${CRASHLYTICS_EMAILS:=""} 118 | 119 | ############################################################################ 120 | # Crashlytics group aliases to be used for upload request 121 | # 122 | # Set this ENV variable before calling this script or the default value will be used. 123 | CRASHLYTICS_GROUP_ALIASES=${CRASHLYTICS_GROUP_ALIASES:=""} 124 | 125 | ############################################################################ 126 | # Crashlytics.framework path relative to SRCROOT (defined on line 143 *DO 127 | # NOT CHANGE SRCROOT*) to be used for upload request. This is the directory 128 | # that contains the Crashlyitics.framework. 129 | # 130 | # Set this ENV variable before calling this script or the default value will be used. 131 | CRASHLYTICS_FRAMEWORK_DIRECTORY=${CRASHLYTICS_FRAMEWORK_DIRECTORY:=""} 132 | 133 | ############################################################################ 134 | # Signing Certificate used to sign the IPA 135 | # 136 | # Set this ENV variable before calling this script or the default value will be used. 137 | SIGNING_IDENTITY=${SIGNING_IDENTITY:="NOT_DEFINED"} 138 | 139 | ############################################################################ 140 | # Provisioning Profile used to provision the IPA 141 | # 142 | # Set this ENV variable before calling this script or the default value will be used. 143 | PROVISIONING_PROFILE=${PROVISIONING_PROFILE:="NOT_DEFINED"} 144 | 145 | ############################################################################ 146 | # used to tell the build system to create and send a tag into Github 147 | # 148 | # Set this ENV variable before calling this script or the default value will be used. 149 | TAG_BUILD=${TAG_BUILD:=0} 150 | 151 | 152 | ############################################################################ 153 | # DO NOT CHANGE ANYTHING BELOW THIS LINE 154 | ############################################################################ 155 | 156 | XCODE_SERVER_DIR="/Library/Developer/XcodeServer" 157 | URL="https://rink.hockeyapp.net/api/2/apps/upload" 158 | PROVISIONING_PROFILE="$XCODE_SERVER_DIR/ProvisioningProfiles/${PROVISIONING_PROFILE}.mobileprovision" 159 | SRCROOT=${SRCROOT:="$XCS_SOURCE_DIR/$SRCROOT_MAIN_DIR/"} 160 | echo "SRCROOT: $SRCROOT" 161 | NOTES=`cd ${SRCROOT}; git log --pretty=format:"%h - %an, %ar : %s" -n 1` 162 | SHA=`cd ${SRCROOT}; git rev-parse HEAD` 163 | DSYM="/tmp/Archive.xcarchive/dSYMs/${PRODUCT_NAME}.app.dSYM" 164 | DSYM_ZIP="${DSYM}.zip" 165 | IPA="/tmp/${PRODUCT_NAME}.ipa" 166 | APP="/tmp/${PRODUCT_NAME}.xcarchive/Products/Applications/${PRODUCT_NAME}.app" 167 | 168 | # Clear out any old copies of the Archive 169 | echo "---------------------------------------------------" 170 | echo "Removing old files from /tmp..."; 171 | /bin/rm -rf /tmp/Archive.xcarchive* 172 | echo "Done removing old files from /tmp"; 173 | echo "---------------------------------------------------" 174 | 175 | # Copy over the latest build the bot just created 176 | echo "---------------------------------------------------" 177 | echo "Copying latest app to /tmp/..."; 178 | echo "ARCHIVE: $XCS_ARCHIVE" 179 | /bin/cp -Rp "$XCS_ARCHIVE" "/tmp/" 180 | echo "Done copying latest app to /tmp/"; 181 | echo "---------------------------------------------------" 182 | 183 | # Create the .ipa to be uploaded 184 | echo "---------------------------------------------------" 185 | echo "Creating .ipa for ${PRODUCT_NAME}" 186 | /usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "${IPA}" --embed "${PROVISIONING_PROFILE}" 187 | echo "Done with IPA creation." 188 | echo "---------------------------------------------------" 189 | 190 | # Create the zipped .dSYM 191 | echo "---------------------------------------------------" 192 | echo "Zipping .dSYM for ${PRODUCT_NAME}" 193 | /bin/rm "${DSYM}.zip" 194 | /usr/bin/zip -r "${DSYM}.zip" "${DSYM}" 195 | echo "Done creating .dSYM for ${PRODUCT_NAME}" 196 | echo "---------------------------------------------------" 197 | 198 | # Upload the build 199 | echo "---------------------------------------------------" 200 | echo "Beginning upload with the following params... " 201 | echo "file: ${IPA}" 202 | echo "dsym: ${DSYM_ZIP}" 203 | echo "api_token: ${HOCKEYAPP_API_TOKEN}" 204 | echo "distribution_lists: ${DISTRO_LIST}" 205 | echo "notes: ${NOTES}" 206 | 207 | UPLOAD_SUCCESS=0 208 | INSTALL_URL="Unkown" 209 | 210 | if [[ -n $HOCKEYAPP_API_TOKEN ]]; then 211 | # HOCKEYAPP_RESPONSE=$(curl "${URL}" --write-out %{http_code} --silent --output /dev/null \ 212 | # -F status=2 \ 213 | # -F notify=1 \ 214 | # -F notes="${NOTES}" \ 215 | # -F notes_type=0 \ 216 | # -F ipa=@$IPA \ 217 | # -F dsym=@$DSYM_ZIP \ 218 | # -F commit_sha=$SHA \ 219 | # -H "X-HockeyAppToken: ${HOCKEYAPP_API_TOKEN}") 220 | 221 | HOCKEYAPP_RESPONSE=$(curl "${URL}" \ 222 | -F status=2 \ 223 | -F notify=1 \ 224 | -F notes="${NOTES}" \ 225 | -F notes_type=0 \ 226 | -F ipa=@$IPA \ 227 | -F dsym=@$DSYM_ZIP \ 228 | -F commit_sha=$SHA \ 229 | -H "X-HockeyAppToken: ${HOCKEYAPP_API_TOKEN}") 230 | 231 | echo Upload API HTTP Response: ${HOCKEYAPP_RESPONSE} 232 | 233 | if [ $HOCKEYAPP_RESPONSE ]; then 234 | UPLOAD_SUCCESS=1 235 | INSTALL_URL=$(echo $HOCKEYAPP_RESPONSE | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["public_url"]') 236 | fi 237 | fi 238 | 239 | if [[ -n $CRASHLYTICS_API_TOKEN ]]; then 240 | echo $NOTES | tee /tmp/ReleaseNotes.txt 241 | if [[ -n $CRASHLYTICS_EMAILS ]]; then 242 | $CRASHLYTICS_FRAMEWORK_DIRECTORY/Crashlytics.framework/submit $CRASHLYTICS_API_TOKEN $CRASHLYTICS_BUILD_SECRET -ipaPath "$IPA" -emails $CRASHLYTICS_EMAILS -notesPath /tmp/ReleaseNotes.txt -notifications "YES" 243 | elif [[ -n $CRASHLYTICS_GROUP_ALIASES ]]; then 244 | $CRASHLYTICS_FRAMEWORK_DIRECTORY/Crashlytics.framework/submit $CRASHLYTICS_API_TOKEN $CRASHLYTICS_BUILD_SECRET -ipaPath "$IPA" -notesPath /tmp/ReleaseNotes.txt -groupAliases $CRASHLYTICS_GROUP_ALIASES -notifications "YES" 245 | fi 246 | UPLOAD_SUCCESS=1 247 | fi 248 | 249 | if [ $UPLOAD_SUCCESS -eq 0 ]; then 250 | if [ $REQUIRE_UPLOAD_SUCCESS -eq 1 ]; then 251 | echo "err: app version not succesfully uploaded." 252 | echo "To ignore this condition and build succesfully, add:" 253 | echo "REQUIRE_UPLOAD_SUCCESS=0" 254 | echo "to the Run Script Build Phase invoking this script." 255 | exit 1 256 | else 257 | echo "err: app version not succesfully uploaded" 258 | echo "ignoring due to REQUIRE_UPLOAD_SUCCESS=0" 259 | fi 260 | else 261 | 262 | VERSION_NUMBER=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${APP}/Info.plist") 263 | BUILD_NUMBER=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${APP}/Info.plist") 264 | BOT_NAME=$(echo $XCS_BOT_NAME | tr -d [[:space:]]) 265 | TAG_NAME="${BOT_NAME}-${VERSION_NUMBER}-${BUILD_NUMBER}" 266 | POST_COLOR=${POST_COLOR:=green} 267 | GITHUB_TAG_URL="" 268 | POST_MESSAGE="$XCS_BOT_NAME Bot: $PRODUCT_NAME $VERSION_NUMBER ($BUILD_NUMBER) is now available!
TestFlight Install URL: $INSTALL_URL
Build Notes: ${NOTES}" 269 | SLACK_MESSAGE=" is now available! \nBuild Notes: ${NOTES}" 270 | 271 | if [ $TAG_BUILD -eq 1 ]; then 272 | echo "Tagging release as '${TAG_NAME}'" 273 | echo `cd ${SRCROOT}; git tag -a ${TAG_NAME} -m "${TAG_NAME}"` 274 | echo `cd ${SRCROOT}; git push -u --tags` 275 | GITHUB_TAG_URL="https://github.com/$GITHUB_ACCOUNT/$SRCROOT_MAIN_DIR/releases/tag/$TAG_NAME" 276 | POST_MESSAGE="$XCS_BOT_NAME Bot: $PRODUCT_NAME $VERSION_NUMBER ($BUILD_NUMBER) is now available!
GitHub Tag: $GITHUB_TAG_URL
TestFlight Install URL: $INSTALL_URL
Build Notes: ${NOTES}" 277 | fi 278 | 279 | if [ $NOTIFY_HIPCHAT_ROOM -eq 1 ]; then 280 | HIPCHAT_ROOM_NAME=$(perl -MURI::Escape -e 'print uri_escape shift, , q{^A-Za-z0-9\-._~/:}' -- "$HIPCHAT_ROOM_NAME") 281 | if [ ! ${HIPCHAT_ROOM_NAME} ]; then 282 | echo "NOTIFY_HIPCHAT_ROOM is set to 1 (true) but HIPCHAT_ROOM_NAME is not set. Can't notify HipChat of build without a valid HIPCHAT_ROOM_NAME." 283 | exit 1; 284 | else 285 | echo "Posting notification to HipChat room: $HIPCHAT_ROOM_NAME" 286 | echo "With message: $POST_MESSAGE" 287 | HTTP_STATUS=$(curl -H "Content-Type: application/json" -d '{"color":"'"$POST_COLOR"'", "message":"'"$POST_MESSAGE"'", "notify":'"$POST_NOTIFY"'}' "https://api.hipchat.com/v2/room/${HIPCHAT_ROOM_NAME}/notification?auth_token=$HIP_CHAT_AUTH_TOKEN" --write-out %{http_code} --silent --output /dev/null) 288 | echo "Finished notifying HipChat room with response code: $HTTP_STATUS" 289 | fi 290 | fi 291 | 292 | if [ $NOTIFY_SLACK_ROOM -eq 1 ]; then 293 | if [ ! $SLACK_INCOMING_WEBSERVICE_URL ]; then 294 | echo "NOTIFY_SLACK_ROOM is set to 1 (true) but SLACK_INCOMING_WEBSERVICE_URL is not set. Can't notify Slack of build without a valid SLACK_INCOMING_WEBSERVICE_URL." 295 | exit 1; 296 | else 297 | echo "Posting notification to Slack using incoming webservice hook URL: $SLACK_INCOMING_WEBSERVICE_URL" 298 | echo "With message: $SLACK_MESSAGE" 299 | HTTP_STATUS=$(curl -H "Content-Type: application/json" -d '{"text": "'"$SLACK_MESSAGE"'","channel": "#general", "username": "buildbot", "icon_emoji": ":leaf:"}' "$SLACK_INCOMING_WEBSERVICE_URL" --write-out %{http_code} --silent --output /dev/null) 300 | echo "Finished notifying Slack room with response code: $HTTP_STATUS" 301 | fi 302 | fi 303 | fi 304 | 305 | echo "Upload process complete" 306 | --------------------------------------------------------------------------------