首页 > 解决方案 > 在非交互式环境中验证和使用 Firebase

问题描述

我使用 Android 移动应用程序,其中源代码在 Azure 中维护。我想根据要求自动化构建过程并在Firebase App Distribution中上传 .apk 文件。

我使用Azure Pipeline来自动化构建过程。我正在使用.yml文件来自动化该过程。能够生成 .apk 文件。我需要将此上传到 Firebase。

关注了几个博客,最后得到了需要在我的 .yml 文件中编写的以下代码

- 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'

有了这个,无法登录到firebase,因为运行时不会有交互。Azure 在运行作业时完全自动化。如果我在命令提示符下使用这些命令,它会打开 firebase 登录页面并在登录时获得身份验证。在该appdistribution:distribute命令成功将应用程序上传到 Firebase 之后。但我需要在 Azure Devops Pipeline 中自动执行此过程,不会有任何交互。

标签: azureazure-pipelinesazure-pipelines-release-pipelinefirebase-toolsfirebase-app-distribution

解决方案


请先尝试生成身份验证令牌,然后使用以下两个选项之一:

  • 将令牌存储为环境变量 FIREBASE_TOKEN。您的系统将自动使用该令牌。
  • firebase在 CI 系统中运行带有 --token 标志的所有命令。

在此处输入图像描述

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


推荐阅读