简体   繁体   English

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

[英]Authenticate and use Firebase in non-interactive environments

I work with Android mobile application, where source code is maintained in Azure.我使用 Android 移动应用程序,其中源代码保存在 Azure 中。 I want to automate the build process and upload the.apk file in Firebase App Distribution , as per the requirment.我想根据要求自动化构建过程并在Firebase App Distribution中上传 .apk 文件。

I used Azure Pipeline to automate the build process.我使用Azure 管道来自动化构建过程。 Am using .yml file to automate the process.我正在使用.yml文件来自动化该过程。 Were able to generate the.apk file.能够生成.apk文件。 I need to upload this to Firebase.我需要将此上传到 Firebase。

Followed few blogs and ends up with below code that needs to be written in my.yml file关注了几个博客,最后得到了下面需要写在 my.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'

With this, couldn't login into firebase, since there will be no interaction on run.有了这个,无法登录到 firebase,因为运行时不会有交互。 It is completely automated by Azure on running the job. Azure 在运行作业时完全自动化。 If I used these commands in command prompt, it open firebase login page and on login it got authentication.如果我在命令提示符下使用这些命令,它会打开 firebase 登录页面并在登录时获得身份验证。 After that appdistribution:distribute command uploads the application to Firebase successfully.之后appdistribution:distribute命令成功将应用程序上传到 Firebase。 But I need to automate this process in Azure Devops Pipeline, where there will be no interactions.但是我需要在 Azure Devops Pipeline 中自动化这个过程,在那里不会有任何交互。

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.将令牌存储为环境变量 FIREBASE_TOKEN。 Your system will automatically use the token.您的系统将自动使用该令牌。
  • Run all firebase commands with the --token flag in your CI system.在 CI 系统中运行所有带有 --token 标志的firebase命令。

在此处输入图像描述

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

I just used firebase login:ci --interactive and worked great for me我刚刚使用firebase login:ci --interactive并且对我很有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Connect-MsolService 非交互式 - Connect-MsolService non-interactive Powershell 中用于 Key Vault 的非交互式登录 - non-interactive login in Powershell for Key Vault 如何将 MailKit 与 IMAP 用于 Exchange 与 OAuth2 用于守护程序/非交互式应用程序 - How to use MailKit with IMAP for Exchange with OAuth2 for daemon / non-interactive apps 通过非交互式 powershell 脚本连接到 Microsoft Teams - Connecting to Microsoft Teams through non-interactive powershell script Azure CLI 无 GUI 虚拟机中的非交互式登录 - Azure CLI non-interactive login in GUIless VM WebAPI使用用户名和密码对Azure AD进行非交互式身份验证 - WebAPI Non-interactive authenticating to Azure AD using username & password 如何使用非交互式身份验证连接到Power BI API? - how to connect to Power BI API using non-interactive authentication? 如何在使用Azure Webjobs和计划部署Web项目时启用非交互式身份验证? - How to enable non-interactive authentication when deploying Web project with Azure Webjobs and schedules? 如何使用Powershell执行非交互式MFA登录到Azure订阅 - How to perform a Non-Interactive MFA Login to Azure Subscription using Powershell 带有MFA的Microsoft Partner Center API基于非交互用户的授权 - Microsoft Partner Center API non-interactive user based authorization with MFA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM