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

Community
  • 1
  • 1
cellardweller
  • 107
  • 1
  • 1
  • 8
  • I've got to go now, so I'll quickly say I think a search of Jenkins + Batch here on this site will turn up an answer, I vaguely remember something about the rights the jenkins service has to run processes... good luck – AjV Jsy Apr 26 '13 at 21:49
  • Does calling from `start` help? That is, calling `start C:\Windows\system32\calc.exe` from the command prompt – Shiva Kumar Apr 27 '13 at 14:41
  • I've seen similar issues. As far as I know you can not interact with the Windows UI from within Jenkins. BTW, if you were to look at the desktop of the Jenkins machine, you would probably see the calc window sitting open on it until you kill the job. – jwernerny Apr 29 '13 at 14:46
  • @jwernerny what do you mean desktop of the Jenkins machine? I'm running Jenkins through a remote desktop connection which has its own desktop (`C:\Users\Jeremy\Desktop`). Is there some other desktop I am not aware of? – cellardweller Apr 29 '13 at 15:20
  • And if I cannot interact with the Windows UI from within Jenkins, how am I supposed to run web tests? What am I not getting? – cellardweller Apr 29 '13 at 15:30
  • @JeremyFalkmann `C:\Users\Jeremy\Desktop` is a desktop folder. The actual Widows Desktop UI (what you would see if you were working on the machine yourself) is different. As for interacting with the UI, the idea of most of the testing I have seen with CI tools like Jenkins is that it is automated, non-interactive testing; not testing that requires interaction. You may want to check what support is available to automate your testing. – jwernerny Apr 29 '13 at 18:56

3 Answers3

7

You cannot open windows processes through Jenkins running as a service. You have to run Jenkins through the console command java -jar "C:\Program Files (x86)\Jenkins\jenkins.war" --httpPort=[your desired available port number]. Then, while Jenkins is running in your console, you should be able to access it in a browser at localhost:[your port number]. Now you may go forth and open calculators and whatever other executables you want.

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

cellardweller
  • 107
  • 1
  • 1
  • 8
0

it worked for me while running jenkins as a service.

cmd.exe /C .\db\your_bat.bat 
laalto
  • 150,114
  • 66
  • 286
  • 303
Karan
  • 371
  • 5
  • 8
0

I faced similar issue in running NI TestStand from Jenkins through services. As @cellardweller said running jenkins.war in cmd prompt created a complete new installation of jenkins, yet it gave me a good solution. Just posting this if any TestStand users struggeling with Jenkins. TestStand is purely a windows app with GUI and it's very much expected that Jenkins service can't execute it.

Ajay
  • 33
  • 1
  • 5