0

I encounter a issue in jenkins job, i want to the jenkins could start IE browser by job automatically to access a website.The slave is a Win7 system and this IE browser's plugin only allow one instance. So my job is like below:

@echo off

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
set isIE=0
for /f %%i in ('tasklist') do (
    rem echo %%i
    if  %%i == iexplore.exe (
       set isIE=1
    )
)

if %isIE% == 1 (
echo "Find IE process, kill them"
taskkill /F /IM "iexplore.exe"
) else (
   echo "No IE process"
)

echo %date% %time%
start iexplore.exe "http://www.example.com"

sleep 5

tasklist | findstr iexplore.exe
echo %date% %time%

You can see, after i start the IE browser, the job will wait 5 seconds and then check the IE process by command:[tasklist | findstr iexplore.exe]. it'll print the IE process information for troubleshooting.

But, if i add this command in the job. The job will close the IE browser after the job executed. I don't know why? If i remove this snippet, the job will start the IE and never close it.. I have no idea at it, Who can help me to find the root cause? Thanks..

David
  • 899
  • 2
  • 10
  • 13

1 Answers1

1

Jenkins will kill any child processes after the job completes. This by design and further explained here.

You can disable this functionality globally all together, by starting Jenkins with:
-Dhudson.util.ProcessTree.disable=true
But better use one of the workarounds provided in that link on per-job basis.

You can also read this post for some ideas on launching an .exe process from Jenkins, just replace excel with IE
Open Excel on Jenkins CI

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