Skip to content

Instantly share code, notes, and snippets.

@xxd
Created December 12, 2012 14:54
Show Gist options
  • Save xxd/4268369 to your computer and use it in GitHub Desktop.
Save xxd/4268369 to your computer and use it in GitHub Desktop.
#####################
# JENKINS step #1
# add to it's own execute shell section
#####################
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
xcodebuild -target GuildBrowserLogicTests \
-sdk iphonesimulator \
-configuration Debug \
TEST_AFTER_BUILD=YES \
clean build | /usr/local/bin/ocunit2junit.rb
#####################
# JENKINS STEP #2
# add to it's own execute shell section
#####################
# tests passed archive app
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
/usr/bin/xcrun xcodebuild -scheme GuildBrowser clean archive \
CODE_SIGN_IDENTITY="iPhone Distribution: Charles Fulton"
echo "App Archived"
#####################
# JENKINS STEP #3
# add to it's own execute shell section
#####################
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
# testflight stuff
API_TOKEN=<insert yours>
TEAM_TOKEN=<insert yours>
#
# Setup
#
# 1
PROJECT="GuildBrowser"
SIGNING_IDENTITY="iPhone Distribution: Charles Fulton"
PROVISIONING_PROFILE="${WORKSPACE}/Charles_Fulton_All_Ad_Hoc.mobileprovision"
# 2
# this is the latest archive from previous build step
ARCHIVE="$(ls -dt ~/Library/Developer/Xcode/Archives/*/${PROJECT}*.xcarchive|head -1)"
# 3
IPA_DIR="${WORKSPACE}"
DSYM="${ARCHIVE}/dSYMs/${PROJECT}.app.dSYM"
APP="${ARCHIVE}/Products/Applications/${PROJECT}.app"
#
# PackageApplication
#
# package up the latest archived build
/bin/rm -f "${IPA_DIR}/${PROJECT}.ipa"
# 4
/usr/bin/xcrun -sdk iphoneos PackageApplication \
-o "${IPA_DIR}/${PROJECT}.ipa" \
-verbose "${APP}" \
-sign "${SIGNING_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"
# zip and ship
/bin/rm -f "${IPA_DIR}/${PROJECT}.dSYM.zip"
# 5
/usr/bin/zip -r "${IPA_DIR}/${PROJECT}.dSYM.zip" "${DSYM}"
#
# Send to test flight
#
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"${IPA_DIR}/${PROJECT}.ipa" \
-F dsym=@"${IPA_DIR}/${PROJECT}.dSYM.zip" \
-F api_token="${API_TOKEN}" \
-F team_token="${TEAM_TOKEN}" \
-F notes="Build ${BUILD_NUMBER} uploaded automatically from Xcode. Tested by Chuck Norris" \
-F notify=True \
-F distribution_lists='all'
echo "Successfully sent to TestFlight"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment