Created
November 22, 2013 14:44
-
-
Save sergii-frost/7600981 to your computer and use it in GitHub Desktop.
Example of commong iOS Jenkins job to build and upload app to TestFlight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fail { | |
echo "$*" >&2 | |
exit 1 | |
} | |
#!/usr/bin/env bash | |
source ~/.bash_profile | |
#hack to add Mercurial to PATH | |
export PATH=$PATH:/usr/local/bin | |
export DEVELOPER_DIR="$XCODE_5_TOOLS" | |
APP_NAME="GordonFreemanApp" | |
PROJECT_DIR="$(PWD)/${APP_NAME}" | |
BUILD_DIR="${PROJECT_DIR}/build" | |
CODE_SIGN_IDENTITY="Gordon Freeman Code Sign Identity" | |
PROVISIONING_PROFILE_ID=... | |
PROVISIONING_PROFILE="/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles/${PROVISIONING_PROFILE_ID}.mobileprovision" | |
# Unlock keychain | |
security unlock-keychain -p <gordon freeman password> ~/Library/Keychains/login.keychain | |
# Clean old build | |
rm -rf "${BUILD_DIR}" | |
cd "${PROJECT_DIR}" | |
# Download pods | |
export LC_ALL="en_US.UTF-8" | |
pod repo update | |
pod install | |
pod update | |
# Set build version | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" ${APP_NAME}/${APP_NAME}-Info.plist | |
/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${APP_NAME}/${APP_NAME}-Info.plist | |
#Running build | |
xcodebuild clean build \ | |
-workspace "$APP_NAME.xcworkspace" \ | |
-scheme "$APP_NAME" \ | |
-configuration "Release" \ | |
CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" \ | |
PROVISIONING_PROFILE="${PROVISIONING_PROFILE_ID}" \ | |
OTHER_CODE_SIGN_FLAGS="--keychain /Users/Shared/Jenkins/Library/Keychains/login.keychain" \ | |
OBJROOT="$BUILD_DIR" SYMROOT="$BUILD_DIR" | |
# Package and sign IPA | |
/usr/bin/xcrun -sdk iphoneos PackageApplication \ | |
"$BUILD_DIR/Release-iphoneos/$APP_NAME.app" \ | |
-o "$BUILD_DIR/Release-iphoneos/$APP_NAME.ipa" \ | |
--sign "${CODE_SIGN_IDENTITY}" \ | |
--embed "${PROVISIONING_PROFILE}" | |
IPA_DIR=$BUILD_DIR/Release-iphoneos | |
IPA=$APP_NAME.ipa | |
DSYM=$APP_NAME.app.dSYM | |
# Move to dir where IPA | |
# NOTE: Seems trivial but makes curl behave better so we don't | |
# need to specify paths containing whitespaces | |
cd "$IPA_DIR" | |
#Need to get last commit information from Git repo. | |
git_notes=`git log -1 --format="SHA1: %H \nAuthor: %an %ar \nDate: %aD \nMessage: %s\n"` | |
echo $git_notes | |
echo "Upload build to TestFlight via curl"; | |
curl http://testflightapp.com/api/builds.json \ | |
-F file=@$IPA \ | |
-F api_token='Gordon Freeman API token' \ | |
-F team_token='Gordon Freeman Team token' \ | |
-F notes="Uploaded on ${BUILD_ID} (Build#: '${BUILD_NUMBER}') (Build version#: '1.0').\nChanges: $git_notes \n\nBest regards,\nGordon Freeman via TestFlight via Jenkins via github" \ | |
-F notify=True \ | |
-F distribution_lists="Gordon Freeman team" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment