Hi,
I've been trying to fix a bug in the scmSkip plugin where pipeline job is marked as aborted, but does not actually stop. I found 4 ways to stop a WorkflowRun
* calling interrupt on either executor (getExecutor or getOneOffExecutor) -- effectively what the plugin does right now, it does not stop the pipeline though
* calling doKill -- kills the job *too* well, even the "post {always}" part is skipped
* throwing AbortException -- stops the job and executes "post {always}", but job is FAILED rather than ABORTED
The following pipeline illustrates the problem:
pipeline {
agent any
stages {
stage('Hello') {
steps {
script {
echo "this should be printed"
// calling interrupt directly, should be done by plugin
currentBuild.rawBuild.getOneOffExecutor().interrupt(Result.ABORTED)
currentBuild.rawBuild.getExecutor().interrupt(Result.ABORTED)
echo "this should be skipped"
}
}
}
}
post {
always {
echo "this should be printed again"
}
}
}
Somehow "this should be skipped" is always printed (at least in environment with SSH agents).
What is the correct way to abort pipeline programmatically?
Thanks,
Zbynek