简体   繁体   中英

Jenkins job windows batch execution 20 times slower than executing in cmd.exe

I just installed Jenkins 2.46.2 on a Windows 2012 Server \o/. It runs as a system service.

I created a job that execute a windows batch (.bat) script to build a code project. This batch results in executing 2 mingw32-make.exe commands to clean and then build a full binary from source code. Executing the batch manually on the machine, located on the same filesystem (same workspace as used by the Jenkins' job, local disk - not network disk), the clean-build takes ~50 seconds.

But when executed by Jenkins, the job takes more than 20x more time longer! (~19 minutes). It terminates succesfully with the same behavior as executed manually in cmd.exe.

I changed the launch arguments for the jvm in the jenkins.xml file with "-Xmx1024m -XX:MaxPermSize=512m" options as I have read in the documentation to improve performance. But it does not fix anything :-(

Also when I monitors the CPU/disk/RAM usages they all stay very very low while building, so I deduce that brute performances of the machine are not in cause.

Whether I invoke the batch with call statement in the Jenkins job build step or not does not change anything : the job always last 19 minutes.

Can anybody help me to investigate why so slowness ?

Thanks in advance :)

I had a similar problem. I noticed that .bat files with echo Hello World ran fast and with no problem.

But once I tried to launch any grep.exe from a batch script, it took 24 seconds (in my case) to run even with no input files. If launched manually it finishes in no time.

I used grep.exe version 2.5.4 from MSys 1.0 distribution.

The solution in my case was rather unexpected - I updated grep to version 2.24, and now, being launched from Jenkins, it takes less than one second to process over 1 MB log file.

For a couple of day investigation, I finally find the cause.

In my case, it is the reason of Jenkins agent.

When I install Jenkins agent as a windows service in the slave agent, the consuming time is so huge,but when I try to start Jenkins agent via windows command line, the consuming time is as normal as executing the batch file manually.

My env:

  • master: CentOS7
  • slave agent: win 7

And I also test this case in a slave agent of win 10 for comparison. The time executing via Jenkins is approximately the same as executing the batch file manually on the agent machine.

So I guess this is the compatibility issue between win 7 and Jenkins. But for that the Jenkins official said that Jenkins not support win 7 anymore (Microsoft does not support Windows 7), we temporarily put it aside.

Anyway we find a way to conquer this. Hope this will help you for similar scenario.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM