小编典典

Gulp在詹金斯不工作

jenkins

我已经全局安装了gulp(npm install gulp
-g)。但是我认为这是行不通的。当我在本地程序上进行gulp测试时,它工作正常。但是,当我在github(在Jenkins上)的同一个程序上进行gulp测试时,会出现以下错误。它不会识别gulp命令。有人能帮我吗?感谢詹金斯的错误:

[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

但是在命令行中它运行良好。

    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

阅读 312

收藏
2020-07-25

共1个答案

小编典典

为了知道您的gulp在哪里,您应该全局(对所有用户)将gulp定义为ENV,或者每次都通过node运行gulp.js:

node node_modules\gulp\bin\gulp.js test

请记住,jenkins对用户变量一无所知,这是为了进行清晰的测试。它知道的唯一的ENV变量是全局变量。

2020-07-25