mrtnlrsn
mrtnlrsn

Reputation: 1255

Kill processes with Jenkins pipeline

I have Jenkins script that executes a Windows application and runs some tests agains it.

With a normal (non-pipeline) Jenkins script, all processes were nicely cleaned up after job completion. It is my understanding that this is done by ProcessTreeKiller.

I try to convert the script to a pipeline script, which works fine, except now the processes are no longer killed.

From this question I see that BUILD_ID must be set in the processes. That is the case.

How do I get pipeline to kill the processes?

Upvotes: 2

Views: 4945

Answers (1)

He Xiang
He Xiang

Reputation: 66

I think you can try to execute batch command after job completion.

For example, if your want to kill all chrome.exe processes, you can write your pipeline like this:

try {
  stage name: "something": 
} catch (err) {
  // handle errors here ? 
} finally {
  bat 'taskkill/F /FI "IMAGENAME eq chrome.exe"'
}

Upvotes: 1

Related Questions