Sharon
Sharon

Reputation: 767

Stop windows batch command on jenkins abort

I'm using Jenkins 2.118 in Windows 7. I created a freestyle project and Use custom workspace.

I added Execute Windows batch command like this. enter image description here

The AutoStart.exe is a console application with no UI, which in turn starts some other child exe's. Once I start the build, the AutoStart.exe is shown up in the task manager and it started the other exe. After some automation job is done by the child exe's, AutoStarted will kill the child exe's and finish its job. Now Jenkins build is successful. Everything is working fine.

Now what I want to do is, once the build is in progress and if i manually abort the jenkins build with the [x] button, enter image description here I need to stop the automation job and kill the child exe's.

What I have done so far?

I assume that once build is aborted, the AutoStart.exe will get killed by jenkins and I write the logic for killing the child exe's in the exit event(taken from here) of AutoStart.exe. The breakpoint never hit in the exit function and I can still see the AutoStart.exe in task manager.

Any and all help is much appreciated. Thanks.

Upvotes: 0

Views: 1252

Answers (1)

Joao  Vitorino
Joao Vitorino

Reputation: 3266

As mentioned here even if you abort the job, the 'Post build task' will run. So you can manage to execute some actions like identify and kill the child's exe's.

Upvotes: 1

Related Questions