2

Ultimately trying to run some NUnit web tests, but I found that Jenkin's would stop before running the batch command path\to\nunit.exe. So I just tried running a new job that consists of a single build step: Execute Windows batch command C:\Windows\system32\calc.exe. Here is my console output:

Started by user anonymous

Building in workspace C:\Program Files (x86)\Jenkins\jobs\[my job]\workspace [workspace] $ cmd /c call C:\Windows\TEMP\hudson8921839713501090632.bat

C:\Program Files (x86)\Jenkins\jobs\[my job]\workspace>C:\Windows\system32\calc.exe

and there it hangs until I cut if off. Needless to say, this command runs fine in command prompt. Also, commands that do not open new processes run fine (e.g. dir) in Jenkins. I don't know what the difference is between running batch commands in cmd.exe and running them through Jenkins. I cannot find any remotely relevant information with a google search of jenkins cannot open exe. Any advice is appreciated.

Edit:

While practicing Shiva's suggestion, I tried observing the running processes while I ran my Jenkins job. If I do not precede the command with start, then calc.exe does run but the interface does not display. Once I kill the jenkins job, calculator is killed as well. If I do include start, then everything is the same except the jenkins job finishes on its own and the calculator continues to run after the job is over. Here is the new log:

Started by user anonymous Building in workspace C:\Program Files (x86)\Jenkins\jobs\First Job\workspace [workspace] $ cmd /c call C:\Windows\TEMP\hudson8285328547956378876.bat

C:\Program Files (x86)\Jenkins\jobs\First Job\workspace>start C:\Windows\system32\calc.exe

C:\Program Files (x86)\Jenkins\jobs\First Job\workspace>exit 0 Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information Finished: SUCCESS

Although this is different behavior, I'm not sure that it offers further enlightenment. Why can I not interact with the running processes?

Possibly related: Jenkins won't execute correctly a command from a .bat

4

3 回答 3

7

您无法通过Jenkins作为服务运行来打开 Windows 进程。您必须Jenkins通过控制台命令运行java -jar "C:\Program Files (x86)\Jenkins\jenkins.war" --httpPort=[your desired available port number]。然后,当 Jenkins 在您的控制台中运行时,您应该能够在 localhost:[您的端口号] 的浏览器中访问它。现在您可以继续打开计算器和您想要的任何其他可执行文件。

https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins

于 2013-04-30T23:22:17.333 回答
0

它在将 jenkins 作为服务运行时对我有用。

cmd.exe /C .\db\your_bat.bat 
于 2013-09-24T05:26:50.787 回答
0

我在通过服务从 Jenkins 运行 NI TestStand 时遇到了类似的问题。正如@cellardweller 所说,jenkins.war在 cmd 提示符下运行创建了一个全新的 jenkins 安装,但它给了我一个很好的解决方案。如果有任何 TestStand 用户与 Jenkins 苦苦挣扎,请发布此内容。TestStand 纯粹是一个带有 GUI 的 Windows 应用程序,并且非常期望 Jenkins 服务无法执行它。

于 2020-06-07T19:25:12.490 回答