How do I use firebase through Bitbucket Pipeline?

I am using angular-cli project and I was using Heroku CD Integration. And the repository is on Bitbucket. Now I am going to use firebase deployment service via Bithubcket pipeline, so I tried as below.

package.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"
  }
}

      

and this is the Bitbucket script pipeline.

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 tried this but it says

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.

      

I'm not sure if the bitbucket line is using docker or some kind of container? On Travis, we have installed the firebase tools as global. npm install -g firebase-tools

But I'm not sure if it will work on the bitbucket pipeline.

Any hints are greatly appreciated.

+3


source to share


1 answer


Try using a different image. Here is an example that uses both angular cli and firebase tool for it. So, you do something like:

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

      

You get "$ FIREBASE_TOKEN" on firebasetool by running:



firebase login:ci

      

Save it in a bit bucket Environment Variables (Settings> Environment Variables) and run the pipeline

+8


source







All Articles