Integrating Firebase App Distribution with Azure DevOps for Android App Testing

Continuous Integration and Continuous Deployment (CI/CD) processes are crucial for the modern development workflow, enabling teams to automate testing and deployment of their applications. For Android development, integrating Firebase App Distribution with Azure DevOps provides a streamlined pathway for distributing app builds to testers efficiently. This article will guide you through setting up Firebase App Distribution within your Azure DevOps pipeline, ensuring your Android app can be tested by your QA team or stakeholders without hassle.

Prerequisites

Before we dive into the setup process, ensure you have the following:

  • An Azure DevOps account with a project set up for your Android app.
  • Your Android project configured in a Git repository managed by Azure DevOps.
  • Firebase project set up for your Android app.
  • Firebase CLI installed on your local machine.

Step 1: Generate a Firebase Token

To interact with Firebase from Azure DevOps, a Firebase token is required. This token authenticates the CI/CD pipeline’s requests to Firebase App Distribution. Follow these steps to generate one:

  1. Install the Firebase CLI on your local machine using npm install -g firebase-tools.
  2. Login to Firebase through the CLI by running firebase login.
  3. Generate a CI token with firebase login:ci. This command outputs a token, which you will need for your Azure DevOps pipeline.

Step 2: Store the Firebase Token in Azure DevOps

After generating the Firebase token, you need to store it securely in Azure DevOps:

  1. Go to your Azure DevOps project.
  2. Navigate to “Pipelines” > “Library”.
  3. Create a new Variable Group or select an existing one.
  4. Add a new variable named FirebaseToken and paste the Firebase token as its value. Ensure to set the variable as a secret.

Step 3: Configure the Azure DevOps Pipeline

With the Firebase token stored securely, you can now configure your Azure DevOps pipeline to use Firebase App Distribution. Here is how you can adjust your pipeline YAML configuration:

yaml

trigger:

- main

pool:

vmImage: 'ubuntu-latest'

variables:

firebaseToken: $(FirebaseToken)

steps:

- task: JavaToolInstaller@0

inputs:

versionSpec: '17'

jdkArchitectureOption: 'x64'

jdkSourceOption: 'PreInstalled'

- task: Gradle@2

inputs:

gradleWrapperFile: 'gradlew'

tasks: 'assembleDebug'

javaHomeOption: 'JDKVersion'

jdkVersionOption: '1.17'

- task: CopyFiles@2

inputs:

SourceFolder: '$(build.sourcesDirectory)/app/build/outputs/apk/debug'

Contents: '**/*.apk'

TargetFolder: '$(build.sourcesDirectory)/deliverables/apk

- script: |firebase appdistribution:distribute $(build.sourcesDirectory)/deliverables/apk/*.apk --app <Your_Firebase_App_ID> --token $(firebaseToken) --groups 'testers'

displayName: 'Distribute APK to Firebase App Distribution'

Replace <Your_Firebase_App_ID> with your actual Firebase App ID. This configuration builds your Android app using Java 17, copies the APK to a specific folder, and then uses a script to distribute the APK to your designated tester group via Firebase App Distribution.

Step 4: Run Your Pipeline

After saving your pipeline configuration, commit it to your repository. Azure DevOps triggers the pipeline on your next commit to the main branch, building your app and distributing it to Firebase App Distribution.

Conclusion

By integrating Firebase App Distribution with your Azure DevOps pipeline, you automate the distribution of your Android app builds. This setup not only saves time but also enhances the efficiency of your testing process, ensuring that your app is rigorously tested and feedback is incorporated swiftly before release. With this powerful combination, you can streamline your development workflow, focus on building quality apps, and deliver updates to your users faster.