2

I have set up Jenkins so that it builds my project, runs some tests and then creates an HTML page containing a report.

I made a .bat file to open the html report in my browser. There is just one line in that .bat file :

"E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest\index.html"

When I run that .bat in a prompt myself, the page index.html is open (so it works).

But the problem is that when I set up a Jenkins' job to run that .bat, nothing happens. The job gets stuck after calling the .bat and never finishes.

Any idea why?

Note: I have other .bat (that do not open html pages) that are successfully executed by Jenkins.

EDIT: here is the errors I get in the prompt log from Jenkins's menu :

C:\Program Files\Jenkins\jobs\JobTest2_enUnSeulScript\workspace>echo " Opening html page" " >> Opening html page"

C:\Program Files\Jenkins\jobs\JobTest2_enUnSeulScript\workspace>"C:\Program Files\Google\Chrome\Application\chrome.exe" "E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest\testResults.14h05m15s65ms.11.04.2013.trx.htm" [688:3900:0411/140520:ERROR:gpu_info_collector_win.cc(96)] Can't retrieve a valid WinSAT assessment.
[688:3900:0411/140520:ERROR:process_singleton_win.cc(540)] Lock file can not be created! Error code: 32
[688:3900:0411/140520:ERROR:chrome_browser_main.cc(1157)] Failed to create a ProcessSingleton for your profile directory. This means that running multiple instances would start multiple browser processes rather than opening a new window in the existing process. Aborting now to avoid profile corruption.
Build step 'Exécuter une ligne de commande batch Windows' marked build as failure [htmlpublisher]
Archiving HTML reports... [htmlpublisher] Archiving at PROJECT level E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest to C:\Program Files\Jenkins\jobs\JobTest2_enUnSeulScript\htmlreports\HTML_Tests_Report Finished: FAILURE

tshepang
  • 12,111
  • 21
  • 91
  • 136
gpalex
  • 826
  • 1
  • 11
  • 27
  • Does the black window of Command Prompt appear? – user2033427 Apr 11 '13 at 11:48
  • No. But I don't think it should appear because the other scripts work and don't display a black prompt neither. But I can access the output of the prompt in Jenkins' menu for the job. It's the text of the prompt in an html page. – gpalex Apr 11 '13 at 12:02
  • I have changed the command line in order to use Internet Explorer to open the html, but the page still not opens when the script is launched with Jenkins (but works when the script is launched manually in a prompt). So the problem is not specific to chrome. When using IE to open the page, I get no error butthe page doesn't open. – gpalex Apr 11 '13 at 12:31
  • If your Jenkins keeps waiting for nothing, you might find that usefull : [Spawning processes from build](https://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build) – gpalex Apr 11 '13 at 12:47

3 Answers3

6

If you are running Jenkins as a Window's service, you will probably need to enable the service to interact with the desktop. Do the following:

  1. Open the Services module
  2. Right-click on Jenkins and select "Properties"
  3. On the "Log On" tab, run as "Local System account" and select the "Allow service to interact with desktop" checkbox

-- OR --

You can run Jenkins via the command-line. Ie: "java -jar jenkins.war".

Robert Greathouse
  • 1,024
  • 1
  • 10
  • 18
1

I am guessing that your Jenkins install is running as a Windows Service. When Jenkins is run as a service on a Windows machine it runs under the System account, not a user account. The System account usually does not have the same settings as a user account.

You might want to try starting a CMD shell as the System Account. (The answers to this question should help you with that: How Do You Run CMD under System Account.) From there, try running the batch file and see what happens. You may find that you need to setup somethings like the PATH before it works.

Community
  • 1
  • 1
jwernerny
  • 6,978
  • 2
  • 31
  • 32
  • Good idea. Instead of running the script as System, I have configured Jenkins' service so that it runs as me (administrator). Unfortunatly nothing changed. – gpalex Apr 11 '13 at 14:26
  • @gpalex It might be interesting to add some statements to your batchfile to dump the environment variables (probably just "SET" will do it) and check what is output when you run it as yourself and when jenkins runs it. – jwernerny Apr 11 '13 at 15:36
0

I know this is late, but I just answered another question on how to open an .exe (or .bat) from Jenkins's service on Windows

Open Excel on Jenkins CI

The issue is that while your command actually works, it does that in Session 0 (which is the session of Local System user that launched your Jenkins service), which you cannot see while being logged in through your own user account, most likely in Session 1.

Hope this helps

Community
  • 1
  • 1
Slav
  • 27,057
  • 11
  • 80
  • 104