Firebase 工具从命令行登录
Firebase tools login from command line
我正在使用 Codeship 部署一个 firebase 应用程序。
为此,我首先需要使用 firebase login
命令登录。问题是,我需要在浏览器中登录,然后 return 到命令行并执行部署。
是否有自动向 Firebase 提供凭据的方法?
干杯
请参阅 以获得更新的版本
一个选择是 mint a token for the build server 并将其传递到 CLI 中:
firebase --token <token>
您还可以从您交互式登录的系统中获取令牌:
firebase login:ci
有关更多选项,请参阅 this page。
接受的答案对于旧版本的 firebase-tools 是正确的,但是从版本 3 开始不推荐使用。获取令牌的新命令是:
firebase login:ci
您应该将其保存在某种环境变量中,理想情况下,FIREBASE_TOKEN。
然后,使用您打算通过 ci(即 deploy
)运行 的任何命令,您可以 运行:
firebase [command] --token [FIREBASE_TOKEN]
firebase login --no-localhost 对我有用。您从浏览器获取授权码,您需要将其粘贴到您的终端 window.
答案:环境变量。
具体来说,使用安装了浏览器和 firebase 工具的机器,运行 firebase login:ci --no-localhost
并将 firebase CLI 工具生成的密钥粘贴到环境变量中并将其命名为 FIREBASE_TOKEN (不是 $FIREBASE_TOKEN)。
在你的部署中,说
npm install -g firebase-tools
firebase deploy
完成。如果你关心为什么?继续阅读。
firebase/firebase-tools repo README 表明以下关于 Usage with CI Systems。
The Firebase CLI requires a browser to complete authentication, but is
fully compatible with CI and other headless environments.
On a machine with a browser, install the Firebase CLI. Run firebase
login:ci
to log in and print out a new access token (the current CLI
session will not be affected).
注意:您实际上想输入 firebase login:ci --no-localhost
Store the output token in a secure but accessible way in your CI
system. There are two ways to use this token when running Firebase
commands:
Store the token as the environment variable FIREBASE_TOKEN and it will
automatically be utilized. Run all commands with the --token <token>
flag in your CI system.
- 注意:您必须使用 --token 标志将您的令牌放在引号 IIF 中
更重要的注意不要在您的环境变量前加上 $ 否则您将在下面收到一条无意义的错误消息!!!
Your CLI authentication needs to be updated to take advantage of new features.
Please run firebase login --reauth
Error: Command requires authentication, please run firebase login
The order of precedence for token loading is flag, environment
variable, active project.
建议使用环境变量,这样秘密令牌就不会 stored/visible 在日志中。
我正在使用 Codeship 部署一个 firebase 应用程序。
为此,我首先需要使用 firebase login
命令登录。问题是,我需要在浏览器中登录,然后 return 到命令行并执行部署。
是否有自动向 Firebase 提供凭据的方法?
干杯
请参阅
一个选择是 mint a token for the build server 并将其传递到 CLI 中:
firebase --token <token>
您还可以从您交互式登录的系统中获取令牌:
firebase login:ci
有关更多选项,请参阅 this page。
接受的答案对于旧版本的 firebase-tools 是正确的,但是从版本 3 开始不推荐使用。获取令牌的新命令是:
firebase login:ci
您应该将其保存在某种环境变量中,理想情况下,FIREBASE_TOKEN。
然后,使用您打算通过 ci(即 deploy
)运行 的任何命令,您可以 运行:
firebase [command] --token [FIREBASE_TOKEN]
firebase login --no-localhost 对我有用。您从浏览器获取授权码,您需要将其粘贴到您的终端 window.
答案:环境变量。
具体来说,使用安装了浏览器和 firebase 工具的机器,运行 firebase login:ci --no-localhost
并将 firebase CLI 工具生成的密钥粘贴到环境变量中并将其命名为 FIREBASE_TOKEN (不是 $FIREBASE_TOKEN)。
在你的部署中,说
npm install -g firebase-tools
firebase deploy
完成。如果你关心为什么?继续阅读。
firebase/firebase-tools repo README 表明以下关于 Usage with CI Systems。
The Firebase CLI requires a browser to complete authentication, but is fully compatible with CI and other headless environments.
On a machine with a browser, install the Firebase CLI. Run
firebase login:ci
to log in and print out a new access token (the current CLI session will not be affected).
注意:您实际上想输入 firebase login:ci --no-localhost
Store the output token in a secure but accessible way in your CI system. There are two ways to use this token when running Firebase commands:
Store the token as the environment variable FIREBASE_TOKEN and it will automatically be utilized. Run all commands with the
--token <token>
flag in your CI system.
- 注意:您必须使用 --token 标志将您的令牌放在引号 IIF 中
更重要的注意不要在您的环境变量前加上 $ 否则您将在下面收到一条无意义的错误消息!!!
Your CLI authentication needs to be updated to take advantage of new features.
Please run firebase login --reauth
Error: Command requires authentication, please run firebase login
The order of precedence for token loading is flag, environment variable, active project.
建议使用环境变量,这样秘密令牌就不会 stored/visible 在日志中。