Building Android Gradle Apps with Jenkins

In this post, you will see how to configure an Android Gradle application in Jenkins. I will use the Gradle Wrapper, as it is usually the preferred way of starting a Gradle build.

The first thing that we need is a simple Android application using Gradle, so I will use a Hello World! application example that you can find on my own GitHub repository (https://github.com/fbelzunc/android-gradle-example ).

Once that I had my plain android-gradle-example with the build.gradle file, I just ran locally "gradle wrapper" to generate the rest of files and folders related to the Gradle Wrapper. After that, I just uploaded my project to the GitHub repository.

Step 1: Install the Gradle plugin

Manage Jenkins->Manage Plugins->[Available] tab and select the Gradle plugin.

Step 2: Choose the Gradle version that you need for your build

For this, go to your Jenkins configuration webpage. On CloudBees you can access from this URL (https://.ci.cloudbees.com/configure). Then, go to the Gradle section and just choose the version that you would like to use on your agent.

Now, we can start creating the Jenkins job for this Android application.

Step 1: Create a free style job called android-gradle-example

Step 2: Put the Git repository used in the SCM section

Step 3: Use the gradlew command on a shell as a part of the build section

Instead of using the shell, you can also use the Invoke Gradle Script as part of the build section.

And this is the end...

GitHub repository: https://github.com/fbelzunc/android-gradle-example

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.