Your first production-ready Jenkins

You heard about Jenkins and you want to try it. Good news: it’s so simple to do it in a production environment. So, skip trying it at your localhost and then installing it again in your production environment. The steps are these:

1. Get a production server. We use to get it at gandi.net. To build Android apps you’ll need 2GB of memory. About the number of cores: it will work with only one core, but if you can afford a machine with more cores, gradle will use them. Fewlaps’ Jenkins has two cores and it performs great.

2. Install Java 8. You can also use Java 7 but… well. At some time, someone, will write a lambda, and you will need to update to Java 8 :·)

su root
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer
java -version
exit

3. Install Jenkinshttps://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins

4. http://yourserver:8080 it works! (note that it’s not too fast starting the daemon)

5. Install git, mercurial… All the things that Jenkins will need to pull your projects from your repos. You know:

apt-get install git
apt-get install mercurial

… and so on

Important: before creating any Job, check your security configuration. Create an user for you, another one for every colleague, and grant them the needed permissions. Also check that “anonymous” doesn’t have any permission, and that the “users can register to the environment” box is not checked.

There’s an issue builiding Android things, related to the AAPT. Fix it with this solution: http://stackoverflow.com/questions/22701405/aapt-ioexception-error-2-no-such-file-or-directory-why-cant-i-build-my-grad