首页 > 解决方案 > travis ci 在 firebase 托管上部署失败

问题描述

我正在尝试将 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.

我不确定出了什么问题。

标签: firebasetravis-cifirebase-hostingfirebase-cli

解决方案


I haven't used the provider function in Travis CI before, but another option of deploying to Firebase hosting is to install firebase-tools and use the CLI.

language: node_js
node_js: 8

before_script:
  - npm install firebase-tools -g

script:
  - firebase deploy --only hosting --token "BnzK...rTI="

-- Edit: More information on Cloud Functions and Branch Filters. --

If you're deploying Cloud Functions as well, you'll need to install the node_modules on travis before you can deploy.

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="

If you want to only deploy when changes are made to the master branch you can add in this filter.

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

推荐阅读