简体   繁体   中英

deploy firebase functions on jenkins: firebase: command not found

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM