0

I've set up a Jenkins build server that's running a nightly build for a Unity project, building two different instances of it. Once these builds are done it runs a job on a different node to copy over the build binaries and run them. What I'm running into is finding a good way for the job to (1) run both executables simultaneously, (2) wait for both of them to finish before moving to the next 'build step' in the job (where it verifies test logs etc).

Initially this seemed to work when I tested it on my own computer: https://stackoverflow.com/a/18762607/14764114 .. but it does not in Jenkins, because the Jenkins node runs as a Windows Service and thus cannot use the START command in Batch.

I'm reading that running separate services might be a solution to explore here, but before I start diving into that I figured I'd ask the community if there isn't a more elegant solution here. In summary, I want to:

  • Run two executables from a Jenkins build step at the same time (from a Jenkins node running on Windows)
  • Wait for both executables to exit before continuing to the next build step
JoeriCG
  • 1
  • 1

1 Answers1

0

In the end I went with this solution, as it seems the Task Scheduler seems to be the only thing capable of starting a Unity game window in my scenario. So I create a task, run it and then delete it, after which I just wait for the processes to disappear from the tasklist:

@echo off

echo "Run FirstApp"
schtasks /create /sc MONTHLY /tn FirstAppTask /tr "%TARGET_DIR%\%APP_First%\FirstApp.exe -automatedtest -duration=%TEST_DURATION_SECONDS%"
schtasks /run /tn FirstAppTask
schtasks /delete /f /tn FirstAppTask

echo "Run SecondApp"
schtasks /create /sc MONTHLY /tn SecondAppTask /tr "%TARGET_DIR%\%APP_Second%\SecondApp.exe -automatedtest -duration=%TEST_DURATION_SECONDS%"
schtasks /run /tn SecondAppTask
schtasks /delete /f /tn SecondAppTask

echo "Wait for FirstApp.exe to end"
:LOOP1
tasklist | find /i "FirstApp" >nul 2>&1
IF ERRORLEVEL 1 (
  GOTO CONTINUE1
) ELSE (
  ping -n 5 ::1 >NUL
  GOTO LOOP1
)

:CONTINUE1

echo "Wait for SecondApp.exe to end"
:LOOP2
tasklist | find /i "SecondApp" >nul 2>&1
IF ERRORLEVEL 1 (
  GOTO CONTINUE2
) ELSE (
  ping -n 5 ::1 >NUL
  GOTO LOOP2
)

:CONTINUE2
echo Done running tests
JoeriCG
  • 1
  • 1