Jack Collins Jack Collins - 1 year ago 222
Groovy Question

How do i kill a process left behind after an aborted Jenkins job, using the groovy script console?

So there has been a process left behind as a result of prematurely ending a build. If this were to happen locally I would open my task manager and kill the process but in this case I have no access to the server. All I have is this groovy script console. Does anyone know how I would go about killing a process in groovy - all I know is its name/path.


Answer Source

You can execute any batch command in groovy by simply calling "execute()" on a string. For example, to kill a process called killme.exe, use this in the groovy script console:

"taskkill /f /im killme.exe".execute();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download