Home > Software design >  deploy firebase functions on jenkins: firebase: command not found
deploy firebase functions on jenkins: firebase: command not found

Time:03-06

I would like to deploy Firebase cloud function on Jenkins but it responds "firebase: command not found".

Here is my execute shell on Jenkins

chmod 755 ./DeployCloudFunction.sh
./DeployCloudFunction.sh

but it output DeployCloudFunction.sh: line 3: firebase: command not found

And this is the DeployCloudFunction.sh below

#!/bin/bash firebase use myProject firebase deploy --only functions

When I run DeployCloudFunction.sh on the terminal on mac, it's working perfectly. I have no idea why it goes wrong when run on Jenkings.

CodePudding user response:

I have also the same error like "Command not found" When I try to deploy my functions with "firebase deploy --only functions" command within my flutter project. There is nothing but only command not found but I was using deploy command from the same folder several times. Sometimes it works sometimes not.

CodePudding user response:

It is very likely that firebase was installed under a different version of npm. For example, you may be using npm 12.19.0, but firebase is installed to npm 10.10.0. Then firebase will not recognize the command.

To fix this, install firebase-tools globally:

npm install -g firebase-tools

Or you could just try adding the npm bin folder to your bash PATH variable. To do that, run:

npm get prefix
And it should output something like /home/your-username/npm-global. Then in your ~/.bashrc or ~/.bash_profile (if you're in a Mac) file, add:
export PATH="/home/your-username/npm-global/bin:$PATH" # Add npm bin PATH

Or try running code below with terminal,

alias firebase="`npm config get prefix`/bin/firebase"

Note : One of the above solutions should work and should be tried in the same order I have written in the answer.

Adding this Github issue and stackoverflow thread for more information.

  • Related