Windows START命令无法从Jenkins Pipeline运行 [英] Windows START command not working from Jenkins Pipeline
问题描述
我的脚本中包含以下代码.
I have following code in my script.
echo Trying to kill all node processes.
taskkill /f /im node.exe
echo Running the application...
start npm run prod
echo Success...
如果我打开命令提示符并从那里运行它,脚本运行良好,但是当我从Jenkins管道运行它时,它没有启动npm run
进程.
The script runs fine if I open a command prompt and run it from there but it doesn't start the npm run
process when I run it from Jenkins pipeline.
奇怪的是构建成功.
有人可以帮我解决这个难题吗? 谢谢. 更新-1 这是詹金斯的输出.
Can anyone help me solve this riddle? Thanks. Update - 1 This is the output in Jenkins.
up to date in 23.58s
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deployment)
[Pipeline] bat
[ABC Pipeline] Running batch script
*************************************
Build Started
@author:
*************************************
Trying to kill all node processes.
ERROR: The process "node.exe" not found.
Running the application...
Success...
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Automation Testing)
[Pipeline] echo
Testing...
[Pipeline] echo
Tests passed!
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
更新-2 npm文件扩展名为.cmd,Windows 10和Jenkins 2.89.4
Update - 2 The npm file extension is .cmd and Windows 10 with Jenkins 2.89.4
推荐答案
Windows服务无法打开新的控制台窗口,但是START
正是在这样做.因此,如果您将Jenkins作为服务运行,则将无法使用.但是,如果仅跳过START
命令,则脚本应该可以正常工作.只需npm run prod
就足够了.
Windows services are not able to open new console windows but START
is doing exactly this. So if you are running Jenkins as a service, this won't work. However, your script should work fine if you simply skip the START
command. Just npm run prod
should be enough.
好,这是一种解决方法:如果确实需要使用start命令,则可以使用任务计划程序创建任务.您可以在其中放置所需的任何批处理代码,也可以将其指向bat文件.使用Schtasks /run /TN TaskName
从詹金斯执行您的任务.
OK, here is a workaround: if you really need to use the start command, you could create a task with the task scheduler. Righ in there you can put any batch code you want or just point it to a bat file. Use Schtasks /run /TN TaskName
to execute your task from Jenkins.
这篇关于Windows START命令无法从Jenkins Pipeline运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!