【问题标题】:travis ci fails deploy on firebase hostingtravis ci 在 firebase 托管上部署失败
【发布时间】:2018-12-12 17:02:08
【问题描述】:

我正在尝试将 travis ci 集成到我的 firebase 应用程序中以自动部署,但它无法显示 401 错误。这是我的 .travis.yml

language: node_js
node_js:
 - '8'
deploy:
  provider: firebase
  token:
   secure: "BnzKtrzBaI/uLHoezYpBVqQ/VwhIyil...n0jAuBNrTI="
  message: build $TRAVIS_BUILD_NUMBER $TRAVIS_BRANCH/$COMMIT_HASH

我收到以下错误:

Error: HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

我不确定出了什么问题。

【问题讨论】:

    标签: firebase travis-ci firebase-hosting firebase-cli


    【解决方案1】:

    我之前没有在 Travis CI 中使用过 provider 功能,但部署到 Firebase 托管的另一个选择是安装 firebase-tools 并使用 CLI。

    language: node_js
    node_js: 8
    
    before_script:
      - npm install firebase-tools -g
    
    script:
      - firebase deploy --only hosting --token "BnzK...rTI="
    

    -- 编辑:关于Cloud FunctionsBranch Filters 的更多信息。 --

    如果您还要部署 Cloud Functions,则需要先在 travis 上安装 node_modules,然后才能进行部署。

    language: node_js
    node_js: 8
    
    before_script:
      - npm install firebase-tools -g
      - cd functions && npm install
    
    script:
      - firebase deploy --only hosting,functions --token "BnzK...rTI="
    

    如果您只想在 master 分支发生更改时进行部署,您可以在此过滤器中添加。

    language: node_js
    node_js: 8
    
    before_script:
      - npm install firebase-tools -g
      - cd functions && npm install
    
    script:
      - firebase deploy --only hosting,functions --token "BnzK...rTI="
    
    branches:
      only:
        - master
    

    【讨论】:

    • 我也无法通过这种方式部署到 Firebase。我收到以下错误``` $ firebase deploy --token "$FIREBASE_TOKEN" --non-interactive === Deploying to 'aradhana-api'... 我正在部署函数,托管 i 函数:确保启用了必要的 API。 .. ✔ 功能:所有必要的 API 均已启用 ... 错误:解析触发器时出错:找不到模块“firebase-functions” 在部署之前尝试在您的函数目录中运行“npm install”。命令 "firebase deploy --token "$FIREBASE_TOKEN" --non-interactive" 以 1 退出。```
    • 您只是想上传到 Firebase 托管,还是同时上传函数?错误是Cannot find module 'firebase-functions' Try running "npm install" in your functions directory before deploying.。这意味着您需要在部署之前在script 中执行cd functions && npm install
    • 但是这样当我在任何分支上合并时它会尝试部署,不是吗? Travis 建议仅使用部署提供程序。关于如何解决它的任何想法?
    • 为您更新了回复。祝你好运!
    • "cd functions && npm install" 给我一个错误:/home/travis/.rvm/hooks/after_use: line 7: printf: 0-next: invalid number $ npm ci npm ERR! JSON 中第 1341 位的意外字符串知道为什么吗?
    猜你喜欢
    • 2020-01-14
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    • 2020-06-14
    • 2014-06-22
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    相关资源
    最近更新 更多