Build Android Project using Jenkins

WS Ayan
2 min readNov 25, 2018

--

I had been trying to build android project in Jenkins for two days. Ended up being completely bald with a successful build after almost 50 broken builds. So I’ve decided to write about how to build an android project in Jenkins for continuous integration without knowing shit about Jenkins and CI (which is continuous integration by the way) on a fucking windows machine. Lets get started then.

First you need these prerequisites:

  1. Forget to ask WHY questions.
  2. Use good old Windows 10 pro OS.
  3. Install JDK and set JAVA_HOME on environment variable.
  4. Install android sdk.
  5. Install gradle.
  6. Install git.
  7. A public git repository of your android project.
  8. Make sure your git repository has gradlew and gradlew.bat files on root directory.
  9. Download jenkins.war
  10. Download and unzip tomcat

Now say goodbyes to your friends,family and loved ones if you have any and follow these steps (try to keep as calm as possible all the way to the end):

  1. Put jenkins.war in webapps/ directory inside tomcat home directory.
  2. Change the default tomcat port number in conf/server.xml inside tomcat home directory.
  3. Run Jenkins on your browser hitting http://localhost:{port number}/Jenkins
  4. Check the tomcat server terminal and you will see a weird credential key hanging on there.
  5. Give the administrative credential key and go on.
  6. Install suggested plugins during first time start. If you don’t you should install git , gradle , pipeline later.
  7. Create a user with a nice username and password.
  8. Go to Manage Jenkins -> Global Security
  9. Click to Enable Security and Allow anonymous read access.
  10. Go to Manage Jenkins -> Configure Systems
  11. Click on Environment Variables. Set ANDROID_HOME as Name and give your android sdk location in Value.
  12. Go to Manage Jenkins -> Global Tool Configuration
  13. Click on JDK installation set name of the JDK and put JDK directory JAVA_HOME
  14. Click on Git installation set name and put git.exe directory.
  15. Click on Gradle installation set name of the gradle and put gradle bin directory from .gradle folder in GRADLE_HOME
  16. Go to New Item.
  17. Give your project name and select Freestyle project.
  18. Click on the item with the bright burning sun icon and enter inside the sacred job.
  19. Go to configure.
  20. Click on Source Code Management tab and select git. Give your git repository url.
  21. Click on Build tab and select Use Gradle wrapper and write build -x lint on Tasks text area.
  22. Hit Save.
  23. Go back to the project directory and hit Build Now.

This article is all about a head start with Jenkins. Options like Build triggers and Post build actions will be discussed later if I don’t leave this planet by then.

--

--

WS Ayan
WS Ayan

Written by WS Ayan

Just another part of the cosmos

No responses yet