firebase - 如何通过 Bitbucket Pipeline 部署 Firebase?

标签 firebase angular-cli webdeploy firebase-tools bitbucket-pipelines

我正在使用 angular-cli 项目,我使用 Heroku 进行 CD 集成。存储库位于 Bitbucket 上。
现在我将通过 Bithubcket 管道使用 firebase 部署服务,所以我尝试如下。

包.json

{
  "name": "mail-activator",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ng build --prod",
    "deploy": "firebase deploy --token $FIREBASE_TOKEN",
    "start": "node server.js"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.1.3",
    "@angular/cli": "1.0.3",
    "@angular/common": "^4.1.3",
    "@angular/compiler": "^4.1.3",
    "@angular/compiler-cli": "^4.1.3",
    "@angular/core": "^4.1.3",
    "@angular/forms": "^4.1.3",
    "@angular/http": "^4.1.3",
    "@angular/material": "^2.0.0-beta.5",
    "@angular/platform-browser": "^4.1.3",
    "@angular/platform-browser-dynamic": "^4.1.3",
    "@angular/router": "^4.1.3",
    "angular2-prettyjson": "^2.0.5",
    "angularfire2": "^4.0.0-rc.0",
    "bootstrap": "^4.0.0-alpha.6",
    "core-js": "^2.4.1",
    "express": "^4.15.3",
    "firebase": "^4.0.0",
    "firebase-tools": "^3.9.0",
    "hammerjs": "^2.0.8",
    "ng2-sweetalert2": "0.0.8",
    "ngx-validators": "^3.0.0",
    "promise-polyfill": "^6.0.2",
    "rxjs": "^5.4.0",
    "sweetalert2": "^6.6.3",
    "zone.js": "^0.8.11"
  },
  "devDependencies": {
    "@angular/cli": "1.0.3",
    "@angular/compiler-cli": "^4.1.3",
    "@types/jasmine": "2.5.47",
    "@types/node": "~7.0.22",
    "codelyzer": "~3.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.0.4",
    "tslint": "~5.3.0",
    "typescript": "~2.3.3"
  }
}

这是 Bitbucket 管道脚本。
image: node:7.6.0

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - npm install
          - npm run postinstall
          - npm run deploy

我试过这个,但它说
i  functions: preparing functions directory for uploading...
Error: Error parsing triggers: Cannot find module 'firebase-functions'
Try running "npm install" in your functions directory before deploying.

我不确定 bitbucket 管道是使用 docker 还是某个容器?在 Travis 上,我们将 firebase-tools 安装为全局。npm install -g firebase-tools
但我不确定它是否适用于 bitbucket 管道。

欢迎任何帮助。

最佳答案

尝试使用其他图像。有一个例子使用 both angular cli and firebase tool为了它。所以你做这样的事情:

image: gabrielaraujof/angular-cli

pipelines:
 default:
   - step:
    script: # Modify the commands below to build your repository.
      - npm install
      - ng build
      - ng test --watch=false
      - firebase deploy --token=$FIREBASE_TOKEN --project project-name-firebase --non-interactive

您可以通过运行以下命令在 firebasetool 上获得“$FIREBASE_TOKEN”:
firebase login:ci

将其保存在位桶的环境变量(设置 > 环境变量)上并运行管道

关于firebase - 如何通过 Bitbucket Pipeline 部署 Firebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44182864/

相关文章:

visual-studio-2010 - Webdeploy 的 MsDeploy 失败

android - 如何退出谷歌认证?

android - Firebase 读取 addValueEventListener onDataChange 值 null

angularjs - 使用 Angular-cli 创建新项目时出错

azure - 在 Azure 应用服务上为 ReactJS 应用程序部署 ZIP 失败

azure - 如何修复 Azure WebApp 的 'The Azure-Ressource is not reachable'

android - 捕获 401 并刷新 Firebase Id token

java - 如何使用 Firestore 仅存储当前登录用户的数据

javascript - 在 webworker 中运行 Angular 5 应用程序会导致窗口对象未定义

javascript - Angular4 + Angular CLI 支持 Javascript AngularJS?