I've been struggling all day trying to get an automated system in place to build my Android apps and I'd appreciate if someone could help me or point me in the right direction. I have a written a shell script which fetches the latest version from Git, builds it and sends the APK to Testflight. This script works properly when I run it myself, but when I setup a cronjob to run it at specified intervals, I run into the following error:

Buildfile: build.xml does not exist!

#!/bin/sh

API_TOKEN=""
TEAM_TOKEN=""
NOTES=$(<Release.txt)
APP_NAME="MainActivity-release.apk"

#Reset git
echo resetting
git reset --hard

echo pull latest
git pull

echo configure for build
android update project -p .

echo build api
ant release

/usr/bin/curl "http://testflightapp.com/api/builds.json " -F file=@"bin/$APP_NAME" -F api_token="$API_TOKEN" -F team_token="$TEAM_TOKEN" -F notes="$NOTES" -#

I've moved this shell script file into my home directory and used

cd ~/Documents/workspace/AutomatedAndroidApp to change directories and then tried the script manually and it worked. However again I had the same error when running it with a cronjob.

I also tried setting the ant -file path with

ant -file ~/Documents/workspace/AutomatedAndroidapp/build.xml

but had no luck. I've never used ant to build my apps before today as I've always used the tools in Eclipse so I'm a bit lost and any help would be appreciated!

有帮助吗?

解决方案

As @ben75 has suggested, this appears to be an issue of the cronjob user differing from the user account that you are using to execute it manually. Thus the ~ will resolve to the wrong user's home directory. Use the full/absolute path instead and pass it to ant with the -file switch.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top