Skip to content

Instantly share code, notes, and snippets.

@onderceylan
Created March 16, 2018 08:41
Show Gist options
  • Save onderceylan/32db2d172f1aec46af253bd4a762521f to your computer and use it in GitHub Desktop.
Save onderceylan/32db2d172f1aec46af253bd4a762521f to your computer and use it in GitHub Desktop.
CI scripts for hybrid mobile apps - Deploy your application to HockeyApp
#!/bin/bash
echo "Deploying QA build to HockeyApp"
commit_message=$(git log --oneline -5)
message=''
strategy='add'
commit_sha=`git rev-parse HEAD`
notify='0'
build_server_url='your-build-plan-url'
repository_url='your-repository-url'
hockey_app_upload_endpoint='https://rink.hockeyapp.net/api/2/apps/upload'
hockey_app_token='your-hockey-app-token-here'
file='Build_Ready_to_Upload.ipa'
if [ ! -f "$file" ]; then
echo "${file} file not found"
exit 1
fi
while getopts 'nrm:' flag; do
case "${flag}" in
n) notify='1' ;;
r) strategy='replace' ;;
m) message="
${OPTARG}" ;;
*) error "Unexpected option ${flag}" ;;
esac
done
# See https://support.hockeyapp.net/kb/api/api-apps#upload-app for API doc
response=$(curl -w 'HTTPSTATUS:%{http_code}' -F ipa=@"${file}" -F status=2 -F notes_type=0 -F notes="${commit_message} ${message}" -F notify="${notify}" -F strategy="${strategy}" -F commit_sha="${commit_sha}" -F build_server_url="${build_server_url}" -F repository_url="${repository_url}" -H "X-HockeyAppToken: ${hockey_app_token}" "${hockey_app_upload_endpoint}")
response_body=$(echo $response | sed -e 's/HTTPSTATUS\:.*//g')
http_status_code=$(echo $response | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
echo "$response_body"
if [ 0 -eq $? ]; then
if [ $http_status_code -eq 201 ]; then
echo "Upload succeeded"
exit 0
fi
echo "Upload failed: Error [HTTP status: $http_status_code]"
exit 2
fi;
echo "Curl request failed"
exit 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment