Home > Blockchain >  Force exe application to run in foreground in Jenkins/Python
Force exe application to run in foreground in Jenkins/Python

Time:07-21

I have a Jenkins job that executes a python script and that python script calls IBM Doors.

In Jenkins the python script is executed like this:

def execute = bat(script: "python -u MyScript.py", returnStdout: true)
echo execute

In the python script, IBM Doors is started like this:

subprocess.Popen(['pathToDoors\\doors.exe', '-osUser'])
Doors = Dispatch('Doors.Application')

After Doors is running I'm executing some dxl scripts using:

Doors.runFile('MyScript.dxl')

The issue is that Doors is always running in background when I start the Jenkins job. The problem with this is that I am not able to see any error messages that Doors might show regarding the dxl script execution. Doors is only started in background, with no GUI when the python script is executed from Jenkins. If I execute that py from the PowerShell/CommandPrompt on the Jenkins slave then Doors is running in foreground with the GUI.

My question is: Is it possible to force exe applications to run in foreground (with GUI) when the python scripts are executed from Jenkins?

CodePudding user response:

Jenkins jobs are run in whichever context Jenkins is running in. This means that, if your Jenkins agent is running as a service, it (and any processes it starts) will run in the background.

If you want your jobs to run in the foreground, you need to run the Jenkins agent in the foreground (i.e. as the logged-in user), rather than as a service.

CodePudding user response:

You can start DOORS in batch mode and give the file to execute as a parameter (doors.exe -batch path\\to\\dxl\\file.dxl). Then DOORS will present its messages on its STDOUT/STDERR that you can catch from your subprocess.

  • Related