在非交互式环境中认证和使用Firebase

问题描述 投票:0回答:1

我使用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 "[email protected]" $(build.artifactStagingDirectory)$(Build.ArtifactStagingDirectory)/android-devops.apk
  displayName: 'npm install and deploy'

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

azure azure-pipelines azure-pipelines-release-pipeline firebase-tools firebase-app-distribution
1个回答
0
投票

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

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

enter image description here

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

© www.soinside.com 2019 - 2024. All rights reserved.