BUILD ANDROID APPLICATION WITH JENKINS PIPELINE

Prashant Bhatasana
AppGambit
Published in
3 min readNov 30, 2019

Most of the organizations in the recent world are using Jenkins as a great tool for automating build processes, continuous integration, and automated deployment. Jenkins helps organizations automate every aspect of the development and save the developers precious time.

In this article, we are talking about how to Build Android Application on Jenkins pipeline.

Following this article, you can also build native as well as hybrid applications also.

Setup Android SDK

If you don’t have setup Android SDK on your machine please follow this article.

Setup Jenkins

If you don’t have setup Jenkins on your machine please follow this article.

After setting up Jenkins we need to configure Android SDK on Jenkins.

Global Properties

Open Jenkins: Manage Jenkins -> Configure System -> Global properties. Mark “Environment variables” and add:

  • ANDROID_HOME : <Path of android-SDK directory>
  • JAVA_HOME : <Path of java-SDK>

Install the plugin from Manage Jenkins

Go to Jenkins Dashboard > Manage Jenkins > Manage Plugins > Available > search for Build Pipeline > Install.

If you are already installed this plugin on your Jenkins it will display in the Installed section.

Create an Android build job

  • Open Jenkins -> New Item. Enter any job name > Choose Pipeline > Click OK.
  • Pipeline > There 2 options for Jenkinsfile.

Pipeline Script

Pipeline Script From SCM

Pipeline Script:

You can write your Pipeline code directly on Jenkins job.

Pipeline Script From SCM:

Pipeline supports fetching the DSL (Domain Specific Language) script from the SCM. Typically called Jenkinsfile and located in the root of the project.

  • Select “Pipeline script from SCM” from the definition.
  • Select Git as SCM
  • Git URL to your repo. Take this URL from Github. It should be the format of git@github.com:{username}/{repo}.git
  • Credentials: Select the one you created before.
  • Branches to build: $branch

For both options, you can use this demo pipeline code.

🎊 🎉🤖🎊 🎉 Our Android project pipeline successfully configured.

Click on Build Now.

Now, you can watch the progress in Console Output. Once the job is finished successfully, you will see the APK.

You can also integrate your build with slack using the Slack Notifications plugin.

You can create a Slack trigger to run this job So you don’t need to open Jenkins whenever you create the build, Just execute the slack command and your build is up and running.

Thank you for reading, if you have anything to add please send a response or add a note!

--

--

Prashant Bhatasana
AppGambit

AWS Community Builder | AWS Certified | Terraform Associate | DevOps Engineer, Love to work with #AWS #Terraform #Jenkins #Kubernetes #Docker #Ansible #Selenium