【问题标题】:Authenticate and use Firebase in non-interactive environments在非交互式环境中验证和使用 Firebase
【发布时间】:2020-04-26 16:48:33
【问题描述】:

我使用 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 中自动化这个过程,不会有任何交互。

【问题讨论】:

  • 我认为this 是你要找的东西
  • 我试过了。在使用“firebase login:ci”命令时,Azure 管道执行会抛出错误消息“无法在非交互模式下运行 login:ci”
  • 据我了解,您必须在可以使用浏览器的地方运行 ci 命令。你将获得一个令牌并在 Azure 管道脚本中使用该令牌。示例 firebase deploy --token
  • 这里的问题是,我无法访问 Web 浏览器,因为它在非交互的 Azure Pipeline 中运行。
  • 必须在装有浏览器的笔记本电脑上运行的 ci 命令。你会在你的笔记本电脑中获得令牌。只需将该令牌从笔记本电脑复制到 Azure 脚本中,您就不必在 Azure 上运行 firebase 登录。

标签: azure azure-pipelines azure-pipelines-release-pipeline firebase-tools firebase-app-distribution


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

    我刚刚使用了firebase login:ci --interactive,对我来说效果很好

    【讨论】:

      猜你喜欢
      • 2016-02-17
      • 2016-05-16
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      相关资源
      最近更新 更多