This matter is quite important for us, so any help is appreciated.
I'm not sure if this is a Jenkins bug or limitation.
During the job build, the flow is reaching the following step (common for both: free-style job and pipeline job):
On line 111 from
AlmToolsUtils.java we launch a long-executing process (C# executable with arguments):
int returnCode = launcher.launch().cmds(args).stdout(out).pwd(file.getParent()).envs(envs).join();
// Starts the process and waits for its completion.
public int join() throws IOException, InterruptedException {
...
final int returnCode = procHolderForJoin.join();
...
}
// Waits for the completion of the process.
public int join() throws InterruptedException, IOException {
...
try {
int r = proc.waitFor();
... |
return r;
} catch (InterruptedException e) {
// aborting. kill the process
destroy();
throw e;
} finally {
t.setName(oldName);
} |
| |
}
If the user aborts the job (so that the InterruptedException is automatically fired by Jenkins), is there a way to call a cleanup (callback) method before the process is killed by destroy()?
(I mean a callback method defined on either plugin-side or C# process-side).
Any suggestions?
Please advise.
Thanks,
Dorin.