I use Cordova CLI to create Android APKs on my Ubuntu 16.04 VPS server. Once the APK has been built I copy it to Dropbox on local machine and then install the APK on my Android test devices. I want to use the Dropbox API to upload the APK directly so I avoid the unnecessary 3 way transfer:
Server -> Local Machine -> Dropbox -> Android test device.
The sequence of operations would go like this
- Shell scripts (already written) on the server cleanup the Android source and rebuild the APK
- This is done with Phonegap/Cordova verbose output on which ensures that a successful build emits the following text at the end
BUILD SUCCESSFUL
Total time: 5.495 secs
Built the following apk(s):
/path/to/app/source/platforms/android/build/outputs/apk/android-debug.apk
No scripts found for hook "after_compile".
No scripts found for hook "after_build".
[36m[phonegap][39m completed 'cordova build android -d --no-telemetry'
The final step - uploading the android apk to my Dropbox should only be done if BUILD SUCCESSFUL is found in the Cordova/Phonegap debug output. I have got everything in place but I am not sure how I should check for BUILD SUCCESSFUL
Here is the pseudocode in the shell script
!# /bin/bash
pgclean;
# pgclean is another shell script that cleans up the Phonegap project in the
# current folder
pgbuild;
# this rebuilds the APK and saves the detailed debug output to
# /path/to/my/project/debug.txt
# it is debug.txt which would contain BUILD SUCCESSFUL etc
Here is where my knowledge of bash scripts hits the buffers. What I would like to do next:
- Test debug.txt, above, to ensure that the build is successful
If so call my final shell script
moveapktodropbox $1
where $1 is the parameter I pass to the current shell script to provide the name under which the APK should be stored in Dropbox.