One click build for PhoneGap Build to Android


/ Published in: Bash
Save to your folder(s)

Basically allows for a one click build through a repository driving PhoneGap Build project.


Copy this code and paste it in your HTML
  1. #! /bin/sh
  2.  
  3. project="[phonegap projectnumber]";
  4. username="[phonegap username]";
  5. password="[phonegap password]";
  6. appPath="[path to www folder]";
  7. projectPath="[path where you want the apk file]";
  8.  
  9. APIPATH="https://build.phonegap.com/api/v1/apps";
  10. FILEPATH="https://build.phonegap.com/apps/";
  11.  
  12. APIcall="$APIPATH/$project"
  13. creds="$username:$password";
  14.  
  15. ##commit changes
  16. echo "Forcing changes to github";
  17. cd $appPath
  18. null=$(git commit -m "auto commit as part of script");
  19. null=$(git push origin master);
  20. echo "Done";
  21.  
  22. cd $projectPath
  23.  
  24. ##Request Phonegap data
  25. echo "Requesting Project Data.";
  26. package=$(curl -s -u $creds $APIcall | grep -Po '"package":.*?[^\\],');
  27. title=$(curl -s -u $creds $APIcall | grep -Po '"title":.*?[^\\],');
  28. title=${title##*:};
  29. title=$(echo $title|sed 's/,//g');
  30. title=$(echo $title|sed 's/"//g');
  31. package=${package##*:};
  32. package=$(echo $package|sed 's/,//g');
  33. package=$(echo $package|sed 's/"//g');
  34. echo "Done. ";
  35.  
  36. ##Request Rebuild
  37. echo "Requesting Rebuild.";
  38. request=$(curl -s -u $creds -X PUT -d 'data={"pull":"true"}' $APIcall);
  39. echo "Done. ";
  40. donecheck="";
  41.  
  42.  
  43. echo "\nWaiting for rebuild to be done.";
  44. while [$donecheck -eq ""]
  45. do
  46. echo ".";
  47. sleep 10;
  48. donecheck=$(curl -s -u $creds $APIcall | grep -Po '"android":"complete"');
  49. done
  50. echo "Done. Now downloading.\n";
  51.  
  52. ##Download File
  53. download=$(curl -L -s -u $creds -o $title-debug.apk $FILEPATH/$project/download/android);
  54.  
  55. ##Install on Device
  56. ~/Downloads/android-sdk/platform-tools/adb uninstall $package
  57. ~/Downloads/android-sdk/platform-tools/adb install -r ./$title-debug.apk

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.