3

I'm iOS developer and I've been playing with Gitlab lately trying to figure out if it's better/more convenient than redmine+jenkins+HockeyApp. Gitlab seems to be quite cool except for I cannot figure out how to upload my ad-hoc iOS build to HockeyApp (or TestFlight). Is it even possible?

Thanks

2 Answers2

3

Yep, this is definitely possible. I'd strongly recommend using the fastlane Ruby gem.

They even have docs for using it with GitLab CI. You can use pilot specifically to upload the build to TestFlight.

Hopefully that helps :)

Connor Shea
  • 795
  • 7
  • 22
0

I ended up with the following configuration:

add deploy.sh file:

#!/bin/bash
echo "deploy to hockeyapp"

HOCKEYAPP_APP_NAME="MyApp.iOS.ipa"
HOCKEYAPP_TOKEN="MyTOKEN"
HOCKEYAPP_ID="MYAPPID"

function buildNotes {

    # We need an initial bullet point for our list of commit logs
    echo -n "* "
    # Get the latest app uploads
    curl -H "X-HockeyAppToken: $HOCKEYAPP_TOKEN" \
    "https://rink.hockeyapp.net/api/2/apps/$HOCKEYAPP_ID/app_versions?page=1" | \
    # Put every property on a separate line
    sed 's/,/\n/g' | \
    # Remove all the quotation marks
    sed 's/"//g' | \
    # Look at only the notes properties
    grep notes | \
    # Look at the first one, i.e. the latest app upload
    head -n 1 | \
    # Find the commit information at the bottom of the notes
    sed -n 's/.*(commit:\([^)]*\)).*/\1/p' | \
    # Let's find all the logs since that commit
    xargs -I '{}' git log {}..HEAD --pretty=format:'%h %s' --no-merges | \
    # Add a star to each newline to make the list
    sed ':a;N;$!ba;s/\n/\n* /g'
    # The end of the revision log must have the latest commit
    # This is so later we can do the above again
    echo
    echo -n "* (commit:"
    git rev-parse HEAD | xargs echo -n
    echo -n ')'
}

function deployAppFlavor () {
    echo "executeCurlCommand"
    curl -F "status=2" \
    -F "notify=1" \
    -F "notes=<release_notes" \
    -F "notes_type=0" \
    -F "ipa=@src/build/MyApp.iOS.ipa/$1" \
    -H "X-HockeyAppToken: $2"\
     "https://rink.hockeyapp.net/api/2/apps/$3/app_versions/upload"
}

function deployApp {
    buildNotes > release_notes
    deployAppFlavor $HOCKEYAPP_APP_NAME $HOCKEYAPP_TOKEN $HOCKEYAPP_ID
}

deployApp

and then update yml file:

 build_project:
   stage: build

   script:
     - xcodebuild clean -workspace MyApp.iOS.xcworkspace -scheme MyApp.iOS -quiet
     - xcodebuild build -workspace MyApp.iOS.xcworkspace -scheme MyApp.iOS -destination 'platform=iOS Simulator,name=iPhone 6s' | xcpretty -s > -quiet

 archive_project:
   stage: archive
   script:
     - xcodebuild clean archive -archivePath "build/MyApp.iOS.xcarchive" -workspace "MyApp.iOS.xcworkspace" -scheme MyApp.iOS -quiet
     - xcodebuild -exportArchive -archivePath "build/MyApp.IOS.xcarchive" -exportPath "build/MyApp.iOS.ipa" -exportOptionsPlist "export.plist" -quiet
   artifacts:
     paths:
       - src/build/MyApp.iOS.ipa

 deploy:
   before_script:
     - chmod +x ./scripts/deploy.sh
   stage: deploy
   script:
     - ./scripts/deploy.sh