Skip to content

Instantly share code, notes, and snippets.

@shiningabdul
Last active January 4, 2016 14:28
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save shiningabdul/8634264 to your computer and use it in GitHub Desktop.
Save shiningabdul/8634264 to your computer and use it in GitHub Desktop.
Xcode Bot Archive Post-Build Script to Upload Automatically to HockeyApp. Updated from here to use Hockey App: http://developmentseed.org/blog/2011/sep/02/automating-development-uploads-testflight-xcode/.
# Valid and working as of 04/21/2014
# Xcode 5.0.1, XCode Server
#
#Settings
API_TOKEN="This can be found here: https://rink.hockeyapp.net/manage/auth_tokens"
DISTRIBUTION_LISTS="This is a comma seperated list of tags found under App -> Users -> "
PROVISIONING_PROFILE="You will have to manually copy your profile to /Library/Server/Xcode/Data/ProvisioningProfiles/<profile>.mobileprovision"
#EXAMPLE:"/Library/Server/Xcode/Data/ProvisioningProfiles/DocLink_InHouse_2013.mobileprovision"
NOTIFY="1"
# 0 - Do not notify, 1 - Notify users by e-mail
STATUS="2"
# 1 - Don't allow users to download, 2 - Available for download
MANDATORY="0"
# 0 - No, 1 - Yes
SIGNING_IDENTITY="This has to be exactly what you see in Keychain -> My Certificates"
#EXAMPLE:"iPhone Distribution: Unwired Revolution, LLC."
# Getting latest commit message
echo "Getting latest commit message"
latest=$(ls -1td /Library/Server/Xcode/Data/BotRuns/Bot* | head -n 1)
echo ${latest}
substringOn=0
blankLineCount=0
commitsString=$(cat ${latest}/output/scm_commit*.log |
awk '{
if (match($0, "CommitDate") == 1) {
substringOn=1
blankLineCount=0
}
if (substringOn==1) {
if ($0 != "") {
if (blankLineCount==1) {
sub(/^[ \t]+/, "",$0)
print $0
}
} else
blankLineCount++
}
}')
echo ${commitsString}
# DO NOT EDIT BELOW HERE!
########################################
DSYM="/tmp/Archive.xcarchive/dSYMs/${PRODUCT_NAME}.app.dSYM"
IPA="/tmp/${PRODUCT_NAME}.ipa"
APP="/tmp/Archive.xcarchive/Products/Applications/${PRODUCT_NAME}.app"
# Clear out any old copies of the Archive
echo "Removing old Archive files from /tmp...";
/bin/rm -rf /tmp/Archive.xcarchive*
#Copy over the latest build the bot just created
echo "Copying latest Archive to /tmp/...";
LATESTBUILD=$(ls -1rt /Library/Server/Xcode/Data/BotRuns | tail -1)
/bin/cp -Rp "/Library/Server/Xcode/Data/BotRuns/${LATESTBUILD}/output/Archive.xcarchive" "/tmp/"
echo "Creating .ipa for ${PRODUCT_NAME}"
/bin/rm "${IPA}"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "${IPA}" --sign "${SIGNING_IDENTITY}" --embed "${PROVISIONING_PROFILE}"
echo "Done with IPA creation."
echo "Zipping .dSYM for ${PRODUCT_NAME}"
/bin/rm "${DSYM}.zip"
/usr/bin/zip -r "${DSYM}.zip" "${DSYM}"
echo "Created .dSYM for ${PRODUCT_NAME}"
echo "*** Uploading ${PRODUCT_NAME} to TestFlight ***"
/usr/bin/curl "https://rink.hockeyapp.net/api/2/apps/acea75fa76b0077c4767e4fcf68ac4e3/app_versions/upload" \
-F notify="${NOTIFY}" \
-F status="${STATUS}" \
-F mandatory="${MANDATORY}" \
-F ipa=@"${IPA}" \
-F dsym=@"${DSYM}.zip" \
-F notes="${commitsString}" \
-F tags="${DISTRIBUTION_LISTS}" \
-H "X-HockeyAppToken: ${API_TOKEN}"
echo "HockeyApp upload finished!"
@zonabi
Copy link

zonabi commented Apr 2, 2014

have you guys had any problem recently where the commit string would not come thru anymore?
it appears the BotRun's commit.log filename has been changed. Not sure why or when.

But the fix we found was:

commitsString=$(cat ${latest}/output/scm_commits*.log |

instead of

commitsString=$(cat ${latest}/output/commit*.log |

peace,
z

@kamleshkatios
Copy link

Hey guys did any have a chance to run the above script on OSX Server 3.2.1.
The path '/Library/Server/Xcode/Data/BotRuns' seems to be not available in OSX Server 3.2.1.

@stevethomp
Copy link

Any thoughts on using this for Xcode 6? the commit log seems to be missing for me now.

@n0quarter
Copy link

kamleshkatios, try /Library/Developer/XcodeServer/IntegrationAssets/Your_Bot/ instead.

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