Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - Node JS + GitHub integration fails on windows 10 during build

I'm trying to configure continues integration for node js using Jenkins version 1.6

Step 1: I have configured NodeJS installations as below by keeping global configuration

Global Configuration

Step 2: My Job Configuration selection node global config here

Job Configuration

Step 3: My Job Console, it is fetching proper git repo while installing npm it fails Job Console

 > C:\Git\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Git\Git\bin\git.exe checkout -f f1612bda9378e7f03738d142a5ce7c0d0a55f6c3
 > C:\Git\Git\bin\git.exe rev-list f1612bda9378e7f03738d142a5ce7c0d0a55f6c3 # timeout=10
Unpacking https://nodejs.org/dist/v6.9.0/node-v6.9.0-win-x86.zip to C:\Users\Selva\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\node_v6.9 on Jenkins
[substack] $ C:\Users\Selva\.jenkins\tools\jenkins.plugins.nodejs.tools.NodeJSInstallation\node_v6.9\node.exe C:\Users\Selva\AppData\Local\Temp\hudson640278178448032292.js
C:\Users\Selva\AppData\Local\Temp\hudson640278178448032292.js:1
(function (exports, require, module, __filename, __dirname) { npm install
                                                                  ^^^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
Build step 'Execute NodeJS script' marked build as failure
Finished: FAILURE
    enter code here

If there is any mistake on which step i need to change,im using windows 10 machine with jenkins stable version

Here i have followed documentation of official jenkins wiki page. Node JS Plugin

Does anyone please help to resolve this Node JS + Github + Jenkins config

like image 325
rselvaganesh Avatar asked Apr 05 '17 12:04

rselvaganesh


1 Answers

On step 2, you shouldn't be running npm install as a step of type Execute NodeJS script.

  • This expects you to enter valid Node Javascript as the Script, for example console.log('I should be valid javascript code').

Leave Provide Node and npm bin/ folder to PATH marked and replace the Execute NodeJS script step with a Windows PowerShell script where you enter npm install as the Script value.

like image 148
Daniel J.G. Avatar answered Sep 18 '22 20:09

Daniel J.G.