简体   繁体   中英

Setting environment variables for a Bamboo build

I have a Bamboo build where one of the things I need to do is execute the npm install command. This all goes fine except for when it hits a dependency that spawns another node instance up to run npm install in the child sub-process. When this happens I get the following error:

12-Oct-2015 12:54:12    
12-Oct-2015 12:54:12    
12-Oct-2015 12:54:12    D:\bamboo-home\xml-data\build-dir\EC-ECB-BUIL\server\node_modules\oracledb>if not defined npm_config_node_gyp (node "c:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild ) 
12-Oct-2015 12:54:12    'node' is not recognized as an internal or external command,
12-Oct-2015 12:54:12    operable program or batch file.
12-Oct-2015 12:54:22    npm ERR! Windows_NT 5.2.3790
12-Oct-2015 12:54:22    npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
12-Oct-2015 12:54:22    npm ERR! node v4.1.2
12-Oct-2015 12:54:22    npm ERR! npm  v2.14.4
12-Oct-2015 12:54:22    npm ERR! code ELIFECYCLE
12-Oct-2015 12:54:22    
12-Oct-2015 12:54:22    npm ERR! oracledb@0.6.0 install: `node-gyp rebuild`
12-Oct-2015 12:54:22    npm ERR! Exit status 1
12-Oct-2015 12:54:22    npm ERR! 
12-Oct-2015 12:54:22    npm ERR! Failed at the oracledb@0.6.0 install script 'node-gyp rebuild'.

It's saying that node is not a recognised command, but I can confirm that it is definitely in the system path and if I execute the commands manually via command prompt, the dependencies install fine (not to mention, all the other dependencies up to this one installed fine).

Does anyone know how to get around this? I've tried setting the system path in Windows and I've tried setting my own environment variables in the Bamboo task itself by adding the following environment variable: PATH="C:\\Program Files\\nodejs" - I'm not sure what else to try.

I had the same problem, and also using oracledb module. The problem is that when npm starts to install the packages, it realizes, that the oracledb package has to be rebuilded. That's why it want's to execute the "node rebuild" command, but don't know what "node" is - as you mentioned, and it happens because it doesn't see your windows agent's environment variables .

The solution is to set the environmet variables one-by-one before executing npm, within your bamboo task .

The best part is, that you cannot use bamboo's npm task (despite it has a parameter for env. variables under advanced options - it didn't work for me). You have to write a normal script task , that looks like someting like that:

REM #Set environment variables
set PATH=........;C:\path\to\nodejs\;........
set OCI_INC_DIR=C:\path\to\oracle\instantclient\sdk\include
set OCI_LIB_DIR=C:\path\to\oracle\instantclient\sdk\lib\msvc
REM #Install node modules
npm i

So your whole PATH variable copied from windows settings, must include path for nodejs! Set also the oracle instant client, then install node packages.

Really ugly and messed up solution, but it works. I have this problem only with windows builds. When building on a linux agent, everything works as it should.

Hope this can help :)

To solve this problem you need to specify advanced settings in the application path 在此处输入图片说明

On Windows, the key for me was doing Path= and not PATH=. Once I corrected the case putting the following under Environment Variables worked for me:

Path=c:\nodejs\bin

'node' is not recognized as an internal or external command operable program or batch file.

i too faced this problem, this is how i rectified it, i set Node.js executable in every task like shown below,

添加新的执行

This makes the bamboo to use the provided executable, not to get the executable path from windows environment path.

Hope this helps.

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