Nightly build for android project using gradle

2019-09-16 05:08发布

问题:

I have an android project which I'm developing in windows environment. Also a remote git repository exist which I push my project to it daily. My requirement is to have a mechanism to automate daily(or nightly) builds. I know that I can build my project in command line by aid of "gardlew.bat". This wrapper is special to my environment (windows) and I need to build the project on remote git repository which is on a linux machine. How can i build my project on a linux machine using command line?

回答1:

As part of your project's root files, you can find "gradlew.bat" that is meant to run on windows machines, and a "gradlew" file that is meant to run on a unix based system.

To build from unix command line, clone your entire project into the linux based machine and run the following command:

./gradlew assembleRelease

You need to make sure that your environment is set up correctly (JDK is installed and JAVA_HOME is configured correctly).

For detailed explanation, please refer to the Android Studio developers site for more information.



回答2:

You can install Jenkins and configure a job for building (and testing, if you have some tests) your application. Configure this job to run periodically (via embedded cron).

Jenkins can

  • clone source code from the repo
  • run gradle with the task(s) specified
  • save *.apk (save artifacts in Jenkins terminology)
  • run tests
  • and many other useful things you may be interested in

Consult https://jenkins.io/index.html