Velos Mobile
Published in

Velos Mobile

Setting up Firebase App Distribution With Automatic Builds from Jenkins

Photo by Adam Wilson on Unsplash

Are you currently using Fabric Beta and wondering how to migrate to Firebase App Distribution using Jenkins Pipeline and allow builds to be distributed easily?

Or do you want to set up Firebase App Distribution from scratch?

This post walks you step-by-step through how to get your builds to Firebase App Distribution using Jenkins, and have builds sent out to testers.

If you have not yet migrated your app from Fabric to Firebase, I recommend checking out this post.

Before you get started, make sure you have the following:

  • Access to your Jenkins build server.
  • Access to Fabric/Firebase project

I’m largely basing this post off of this page: Distribute with Gradle. We use Jenkins Pipeline, and this post is written in that context.

Let’s get started!

Step 1: Set up dependencies.

  1. Add the appdistribution plugin to the top of your app/build.gradle file:
apply plugin: ''

2. Inside the buildscript block, add your firebase-appdistribution dependency. Here’s the entire buildscript block:

buildscript {
repositories {
dependencies {
classpath ''

Step 2: Set up a Service Account for authentication.

A service account allows

  1. Go to Firebase Console and select your project.
  2. Click on project settings on the left top corner.

3. Select “Service Accounts” from the tab, and choose the “Manage service account permissions” link.

4. Select “CREATE SERVICE ACCOUNT” in this view, and you will see a screen that looks like this:

Fill in the details and press CREATE.

5. You will see a screen to give Service account permissions (optional). Here, select a role that is Firebase Quality Admin. This gives access to the Firebase Quality products, including App Distribution.

Press Continue when you’re done.

6. The last step here is to choose “CREATE KEY” and download the JSON file. This JSON File is the service credentials file that we need in the next step, and it will help authenticate Jenkins for automatic builds for App Distribution. Keep this file safe! You may want to rename it to something like service-credentials-projectname.json

Step 3: Set up your testers in Firebase.

Go to ‘Testers & Groups’ tab under Firebase App Distribution.

You can set up your testers individually, or as a group. In my scenario, I’ve created a group called velos_testers and added a few testers.

You will refer to this group in the build.gradle file in the next step.

Step 4: Set up the Service Account credentials file locally.

On the Firebase App Distribution documentation, we are given two options for authenticating service accounts.

Authenticating with a service account allows you to flexibly use the plugin with your continuous integration (CI) system. There are two ways to provide service account credentials:

1. Pass your service account key file to build.gradle. You might find this method convenient if you already have your service account key file in your build environment.

2. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to your service account key file. You might prefer this method if you already have ADC configured for another Google service (e.g., Google Cloud Platform).

Option #1 is great for setting up and testing if builds are going through when running

./gradlew assembleRelease appDistributionUploadRelease

on your local machine.

Option #2 (Step 4) is what we will eventually need to get automatic builds from Jenkins.

We will start with Option #1 to make sure everything is set up properly.

  1. Add your service-credentials-projectname.json file to the root-level of the project (at the same level as app/ and settings.gradle). Make sure to add the file to .gitignore if you don’t wish to push the file to your repository.
  2. Add firebaseAppDistribution details to app/build.gradle.

You can read about this setup here.

For our scenario, I’ve just set up app/build.gradle to distribute the release build to testers.

firebaseAppDistribution {
releaseNotes = "Test Notes"
serviceCredentialsFile = "$rootDir/seasonal-android-firebase.json"

You should now be able to run

./gradlew assembleRelease appDistributionUploadRelease

in your Terminal, and see that a build showed up in Firebase App Distribution under the “Distributions” tab.

*Note: Test users will not receive an email every time a new build is published.

Step 5: Use Firebase App Distribution to distribute Jenkins builds.

If you saw builds coming up in Firebase App Distribution, and your test users have received at least one email from Firebase, you know that everything is set up properly on the Firebase side.

Now, it’s time to configure Jenkins Pipeline to distribute builds to your tester group through Firebase.

  1. SSH into your Jenkins server, and add the credentials file at an appropriate location. (You may instead want to create a new key for Jenkins and use that file on the Jenkins server).

Make sure that the file has read access.

2. Set the environment variable, GOOGLE_APPLICATION_CREDENTIALS. This is what Firebase uses when looking for the credentials file.

There is more information on this here.

export GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/credentials/file.json

3. Modify Jenkinsfile to configure two things:

  • Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the credentials file you previously uploaded.
  • Run the gradle app distribution command: ./gradlew assembleRelease appDistributionUploadRelease

The Jenkinsfile for our sample project looks like this:

The important part is to make sure that the


variable is being set, and adding

./gradlew assembleRelease appDistributionUploadRelease

as part of the distribution phase.

4. Make sure you modify the app/build.gradle file to use the new GOOGLE_APPLICATION_CREDENTIALS environment variable in place of the local credentials file:

firebaseAppDistribution {
releaseNotes = "Test Notes"
serviceCredentialsFile = System.getenv("GOOGLE_APPLICATION_CREDENTIALS")

At this point, you can remove the local credentials file completely if you are only distributing builds through Jenkins.

And that’s it! I hope this tutorial was useful for you in getting your Firebase App Distribution running with Jenkins.

Is there something you did differently? Share it in the comments!




We are a group of technologists who are passionate about creating excellent mobile experiences. We’ve been doing this for a long time, and we love sharing our expertise from the first wireframe to the last bug. Check us out at

Recommended from Medium

Laravel Advance | Laravel custom validation rules example

How to install Airflow on Ubuntu 20.04

The 3 types of SD-WAN architecture

The game of Pig in Java

Custom SMS commands with Twilio and PHP

Patract Weekly Report#10 (24th-28th,May)

Why need of consistent hashing ???

The pursuit of happiness with Python and PostgreSQL

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Seetha Annamraju

Seetha Annamraju

Android developer, traveler, mentor, vegan foodie.

More from Medium

Firebase push notifications in ionic capacitor app (Android)

How to send SMS programmatically from an Android application

Migrate android studio project to vscode

Remote Debug Android Device using Chrome DevTools