Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp won't work in Jenkins

I've installed gulp globally (npm install gulp -g). But this isn't working I think. When I'm doing gulp test on my local program it works fine. But when I'm doing a gulp test on my (the same) program from github (on Jenkins), it gives the following error. It won't recognize the gulp command. Can someone help me? Thanks Error in Jenkins:

[EnvInject] - Loading node environment variables.
Building in workspace C:\Program Files (x86)\Jenkins\workspace\project1
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url https://github.com/Jelle7/project1.git # timeout=10
Fetching upstream changes from https://github.com/Jelle7/project1.git
 > C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe -c core.askpass=true fetch --tags --progress https://github.com/Jelle7/project1.git +refs/heads/*:refs/remotes/origin/*
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 6fe866ee6937a4862ac501c6ce185eda64067ed8 (refs/remotes/origin/master)
 > C:\Program Files (x86)\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files (x86)\Git\bin\git.exe checkout -f 6fe866ee6937a4862ac501c6ce185eda64067ed8
 > C:\Program Files (x86)\Git\bin\git.exe rev-list 6fe866ee6937a4862ac501c6ce185eda64067ed8 # timeout=10
[karma-test] $ cmd /c call C:\Windows\TEMP\hudson8554225917848574447.bat

C:\Program Files (x86)\Jenkins\workspace\project1>gulp test 
gulp is not recognized as an internal or external command

C:\Program Files (x86)\Jenkins\workspace\project1>exit 9009 
Build step 'Run Windows batch command.' marked build as failure
Finished: FAILURE

But in commandline it worked well.

    C:\Program Files (x86)\Jenkins\workspace\project1>gulp test
[15:18:56] Using gulpfile C:\Program Files (x86)\Jenkins\workspace\project1\gulp
file.js
[15:18:56] Starting 'scripts'...
[15:18:57] all files 3.26 kB
[15:18:57] Finished 'scripts' after 387 ms
[15:18:57] Starting 'test'...
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
WARN [watcher]: Pattern "C:/Program Files (x86)/Jenkins/workspace/project1/src/*
*/*.mock.js" does not match any file.
INFO [PhantomJS 1.9.8 (Windows 7)]: Connected on socket qZEPgByCA2MGyk1w_0TI wit
h id 43463083
PhantomJS 1.9.8 (Windows 7): Executed 1 of 1 SUCCESS (0.01 secs / 0.017 secs)
[15:18:59] Finished 'test' after 2.44 s
like image 493
lvthillo Avatar asked Apr 02 '15 06:04

lvthillo


People also ask

Why is gulp not working?

To solve the error "'gulp' is not recognized as an internal or external command, operable program or batch file", install the gulp-cli package globally by running npm install -g gulp-cli , restart your terminal and make sure your PATH environment variable is set up correctly.

Why is gulp command not found?

The problem might be caused by your global npm directory being set to the wrong location. The global npm directory is where your packages get installed when you install them globally. You can check where it is by typing in npm root -g in the command line.

How do I know if gulp is installed?

First run npm -g install gulp-cli then run gulp -v. Alternatively, you can just run npm list gulp.

How do I run a gulp file?

in the Before launch area and choose Run Gulp task from the list. In the Gulp task dialog that opens, specify the Gulpfile. js where the required task is defined, select the task to execute, and specify the arguments to pass to the Gulp tool. Specify the location of the Node.


2 Answers

On your windows machine go to the Jenkins service properties and change the logon user to a user other than System for the Jenkins service. I used my logged on user credentials to get it to work and now I am running gulp commands to build from Jenkins on my windows slave with no problem all. node, npm and gulp commands are all recognized.

like image 192
Kyle Avatar answered Oct 17 '22 16:10

Kyle


For making know where your gulp is you should define gulp to ENV globally (for all users) or just run gulp.js via node every time:

node node_modules\gulp\bin\gulp.js test

Remember that jenkins doesn't know anything about your user variables, this is made for clear testing. The only ENV variables it knows are the global ones.

like image 32
Stan E Avatar answered Oct 17 '22 17:10

Stan E