1

I work with Android mobile application, where source code is maintained in Azure. I want to automate the build process and upload the .apk file in Firebase App Distribution, as per the requirment.

I used Azure Pipeline to automate the build process. Am using .yml file to automate the process. Were able to generate the .apk file. I need to upload this to Firebase.

Followed few blogs and ends up with below code that needs to be written in my .yml file

- script: |
    cd functions
    npm init --yes
    npm install -g firebase-tools
    npm install
    firebase login --interactive
    firebase appdistribution:distribute --app APP_ID --release-notes "My first distribution" --testers "xyzh@gmail.com" $(build.artifactStagingDirectory)$(Build.ArtifactStagingDirectory)/android-devops.apk
  displayName: 'npm install and deploy'

With this, couldn't login into firebase, since there will be no interaction on run. It is completely automated by Azure on running the job. If I used these commands in command prompt, it open firebase login page and on login it got authentication. After that appdistribution:distribute command uploads the application to Firebase successfully. But I need to automate this process in Azure Devops Pipeline, where there will be no interactions.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Joseph
  • 1,060
  • 3
  • 22
  • 53
  • I think [this](https://stackoverflow.com/q/33939143/1723745) is what you are looking for – Akshay Jain Apr 26 '20 at 17:10
  • I tried with that. And on having 'firebase login:ci' command, the Azure pipeline execution throws error with message "Cannot run login:ci in non-interactive mode" – Joseph Apr 27 '20 at 05:53
  • As I understand you have to run the ci command where you can have the browser. You will get a token and use that token in the Azure pipeline script. Example firebase deploy --token – Akshay Jain Apr 27 '20 at 06:08
  • The problem here is, I do not have access to web browser since this runs in Azure Pipeline which is non interactive. – Joseph Apr 27 '20 at 08:51
  • the ci command you have to run on your laptop where you have the browser. And you get the token in your laptop. Just copy that token from laptop into the Azure script so that you don't have to run the firebase login on Azure. – Akshay Jain Apr 27 '20 at 09:14
  • How long it will have the authentication token valid ? If it is short period of time, every time when I want to run the pipeline (may be once in a day), do I have to generate token manually – Joseph Apr 27 '20 at 09:54
  • Although I don't see any official statement on this - it looks like the token won't expire at all. "Maybe" the token doesn't expire until new token is generated. I'll suggest reach out to [firebase support](https://firebase.google.com/support) with the query. – Akshay Jain Apr 27 '20 at 10:03
  • Thanks. Will do that. – Joseph Apr 27 '20 at 10:54

2 Answers2

4

Please try to generate an authentication token first, and then use either of the following two options:

  • Store the token as the environment variable FIREBASE_TOKEN. Your system will automatically use the token.
  • Run all firebase commands with the --token flag in your CI system.

enter image description here

https://firebase.google.com/docs/cli/#command_reference

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
1

I just used firebase login:ci --interactive and worked great for me

Hadi tavakoli
  • 1,267
  • 2
  • 16
  • 30