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
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.
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.
来源:https://stackoverflow.com/questions/29406533/gulp-wont-work-in-jenkins