$30 off During Our Annual Pro Sale. View Details »

Jenkis CI: Release and Testing Automation for iOS

Jenkis CI: Release and Testing Automation for iOS

I gave this talk at TACOW Toronto on March 7, 2017. It focuses on how we have our Jenkins continuous integration setup at Hipo and how it supports our development and testing processes.

Sample build scripts are shared at https://github.com/Hipo/jenkins-ios-automation

Taylan Pince

March 07, 2017
Tweet

More Decks by Taylan Pince

Other Decks in Programming

Transcript

  1. Jenkins CI Build Automation, Testing & Release Distribution

  2. None
  3. None
  4. None
  5. brew install jenkins

  6. None
  7. None
  8. Project Setup

  9. None
  10. None
  11. None
  12. None
  13. None
  14. None
  15. None
  16. None
  17. None
  18. Release Process

  19. None
  20. 1. Clean /usr/bin/xcodebuild \ -workspace "$XCODE_WORKSPACE_PATH" \ -scheme "$XCODE_SCHEME" \

    -configuration "$XCODE_CONFIG" \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO \ clean || die "Clean failed"
  21. die() { echo "$*" >&2 exit 1 }

  22. 2. Update dependencies /usr/local/bin/pod repo update /usr/local/bin/pod install

  23. 3. Build & Run Unit Tests /usr/bin/xcodebuild \ -workspace "$XCODE_WORKSPACE_PATH"

    \ -scheme "$XCODE_SCHEME" \ -configuration "$XCODE_CONFIG" \ -sdk iphoneos \ OBJROOT="$PWD/build" \ SYMROOT="$PWD/build" \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO
  24. 4. Update Provisioning ./deploy/resign_with_device.rb \ tryouts-app-id="$TRYOUTS_APP_ID" \ tryouts-token="$TRYOUTS_APP_TOKEN" \ itunes-token="$ITUNES_TOKEN"

    \ team-id="$TEAM_ID" \ app-name="$APP_NAME" \ bundle-identifier="$APP_BUNDLE_IDENTIFIER" \ provision-output-path="$PROVISION_PATH"
  25. None
  26. 5. Load Keychain KEYCHAIN_PATH="/usr/local/keychains/$KEYCHAIN_NAME.keychain" /usr/bin/security list-keychains \ -s "$KEYCHAIN_PATH" /usr/bin/security

    default-keychain \ -s "$KEYCHAIN_PATH" /usr/bin/security unlock-keychain \ -p "$KEYCHAIN_PASSWORD"\ "$KEYCHAIN_PATH"
  27. 6. Archive /usr/bin/xcodebuild \ -workspace "$XCODE_WORKSPACE_PATH" \ -scheme "$XCODE_SCHEME" \

    -configuration "$XCODE_CONFIG" \ -sdk iphoneos \ ONLY_ACTIVE_ARCH=NO \ CODE_SIGN_IDENTITY="$DEVELOPER_NAME" \ PROVISIONING_PROFILE="$PROVISIONING_UUID" \ archive -archivePath "$APP_ARCHIVE_PATH"
  28. 7. Sign /usr/bin/xcodebuild -exportArchive \ -archivePath "$APP_ARCHIVE_PATH" \ -exportPath "$OUTPUT_PATH"

    \ -exportOptionsPlist \ "$PWD/deploy/export_options.plist"
  29. 8. Generate Release Notes PREVIOUS_TAG=`git describe HEAD^1 --abbrev=0 --tags` GIT_HISTORY=`git

    log --no-merges --format="- %s" $PREVIOUS_TAG..HEAD` RELEASE_DATE=`date '+%Y-%m-%d %H:%M:%S'` RELEASE_NOTES="Build: $CURRENT_TAG Uploaded: $RELEASE_DATE $GIT_HISTORY"
  30. 9. Distribute curl https://tryouts.io/applications/$TRYOUTS_APP_ID/upload/ \ -F status="2" \ -F notify="0"

    \ -F notes="$RELEASE_NOTES" \ -F build="@$IPA_PATH" \ -H "Authorization: $TRYOUTS_APP_TOKEN"
  31. None
  32. UI Tests

  33. None
  34. 1. Prepare Simulator Build /usr/bin/xcodebuild \ -workspace "$XCODE_WORKSPACE_PATH" \ -scheme

    "$XCODE_SCHEME" \ -configuration "$XCODE_CONFIG" \ -sdk iphonesimulator \ OBJROOT="$PWD/build" \ SYMROOT="$PWD/build" \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO
  35. 2. Upload to Saucelabs zip -r "$SIM_ZIP_PATH" "$SIM_APP_PATH" curl -u

    $SAUCELABS_USERNAME:$SAUCELABS_TOKEN \ -X POST "http://saucelabs.com/rest/v1/storage\ /$SAUCELABS_USERNAME/$APP_NAME.zip?overwrite=true" \ -H "Content-Type: application/octet-stream" \ --data-binary "@$SIM_ZIP_PATH"
  36. 3. Run Robot Tests /usr/local/bin/pybot -- chromaios.robot

  37. login_with_username openapp wait until page contains element ${Power_Button} tap ${Power_Button}

    verify login options page is opened with email signin with email sleep 3s #verify signin page is opened enter email ${user1_email} enter password ${user1_password} ok, sign in wait until page contains element ${Main_AddFigure_Button} page should contain text Following [Teardown] close application
  38. Gotchas

  39. Thank You! taylan@hipolabs.com @taylanpince github.com/hipo/jenkins-ios- automation