Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins And android Build

I am trying to automate the android build process using Jenkins

I am using the following site to achieve this Link to site

I am successfully able to Build it on my own machine. Initially i got error saying that build.xml file not found (build using ant requires this file). So i execute "android update project". So it automatically generate all necessary file for ant.

Now my problem begins when i tried to host my repo to remote server and tried to build from another machine. The error it is giving is the sdk.dir is not correct. When i analysed the project folder ther is a file called local.properties which contains the SDK path of my first machine which is wrong for other machines. So i add that file to gitignore. Now that file is not tracking and because of this the build is failing.

So is there any way to automatically generate the files that is necessary for ant after jenkins is cloning project from the remote repo?

like image 897
Hashim MH Avatar asked Feb 12 '13 11:02

Hashim MH


2 Answers

From the website you link to, they precisely explain how to configure sdk.dir:

Configuring the environment

When jenkins builds your project with Ant, it needs to know where your android sdk folder is. To do this, click Advanced on the Ant target build step you just configured and add the following variable to the Properties field. sdk.dir=/opt/android-sdk-linux/

Don’t forget to substitute the value of the variable with the correct location where the Android SDK is installed on your build server.

Job configuration is done. Click Save. Time to test your build.

like image 69
etienne Avatar answered Sep 28 '22 08:09

etienne


We also build android apps with Jenkins, and also need to edit the local.properties.

In my case, I have the file updated with the path to SDK by the Jenkins build itself. Just before the build starts.

You can use a simple sed command on linux or echo the content on windows (overwriting content).

Example flow:

  1. SCM - get sources
  2. Edit the local.properties (as suggested before)
  3. Run ant build

Note - if you are using the "Invoke Ant", you should add an "Execute Shell" step before to deal with the editing of the local.properties.

I hope this helps.

like image 30
Eldad Assis Avatar answered Sep 28 '22 08:09

Eldad Assis