BitBucket Firebase Pipeline error

RobT April 7, 2022

I'm getting a strange error when I get to the deploy step of firebase.

The config (/bitbucket-pipeline.yaml) steps look like this...

image: node:16

pipelines:
branches:
dev:
- step:
name: Setup
caches:
- node
script:
- npm install
- step:
name: Build
caches:
- node
script:
- npm run build:dev
artifacts:
- build/**
- step:
name: Deploy
caches:
- node
deployment: staging
script:
- pipe: atlassian/firebase-deploy:1.3.0
variables:
PROJECT_ID: $FIREBASE_PROJECT_ID
KEY_FILE: $FIREBASE_PRIVATE_KEY
DEBUG: "true"

The (/package.json) file looks something like this (hopefully this is all the relevant parts)...

{
...
"engines": {
"node": 16
},
...
"dependencies": {
...
"firebase": "^9.6.1",
...
"react-scripts": "5.0.0",
...
},
"scripts": {
...
"build:dev": "env-cmd -f .env.development react-scripts build",
...
}
}

The deployment error looks like this...

Status: Downloaded newer image for bitbucketpipelines/firebase-deploy:1.3.0
DEBUG: Starting new HTTPS connection (1): bitbucket.org
DEBUG: https://bitbucket.org:443 "GET /bitbucketpipelines/official-pipes/raw/master/pipes.prod.json HTTP/1.1" 200 None
INFO: Executing the pipe...
INFO: Current NodeJS version:
installing : node-v12.22.12
mkdir : /usr/local/n/versions/node/12.22.12
fetch : https://nodejs.org/dist/v12.22.12/node-v12.22.12-linux-x64.tar.gz
installed : v12.22.12 (with npm 6.14.16)
Traceback (most recent call last):
File "/main.py", line 170, in <module>
pipe.run()
File "/main.py", line 108, in run
key_content = base64.b64decode(key_file)
File "/usr/local/lib/python3.7/base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

I can't see anything out of the ordinary. Could anyone please point me at what might be wrong?

1 answer

1 accepted

1 vote
Answer accepted
o_kyrdan April 8, 2022

Hi @RobT

Looks like the KEY_FILE encoding error.

The KEY_FILE should be base64 encoded content of Key file for a Google service account. To encode this content, follow encode private key docs.

 

Linux

$ base64 -w 0 < my_gcp_key

Mac OS X

$ base64 < my_gcp_key

 

More details about firebase-deploy pipe you could find in the Readme.

 

Best regards,
Oleksandr Kyrdan

RobT April 11, 2022

Thank you @o_kyrdan , that was exactly it. I missed the base64 part. Silly mistake.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events