Hello everybody,
I initially asked this question a week ago, but somehow it didn't go
through. Since I am quite certain that this is rather a *dev* than a *user*
question, I will try to bring it up here again...
I am developing a Jenkins plugin that can be used in a traditional
Freestyle project as well as in Pipeline mode. In certain circumstances, I
want the plugin to abort the entire Jenkins job as a continued build
process of the project is not of any use anymore.
Thus, I am throwing an AbortException within the run method of the
StepExecution class:
run.setResult(jenkinsResult);
if (jenkinsResult == Result.ABORTED) {
throw new AbortException("Aborted due to failure during QF-Test build
step");
}
In pipeline mode, this works as expected. The first line is not even
needed, even without it, the build stops and will be marked as ABORTED.
However, in freestyle mode, the exception gets caught here:
https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Run.java#L1886
The build seems to terminate (as requested), but the result will be *forced
to FAILURE *(instead of ABORTED, which is what I would expect). I know that
I can achieve the ABORT state by "interrupting" the build. But interrupting
seems to encode the user actively stopping the build e.g. by clicking the
red cross. Whereas the *AbortException* message gets mentioned on the
console log, the *interrupt* simply stops the build without further notice.
In this light, I wouldn't say that my use case (the plugin stopping the
build autonomously) should be handled by the interrupt mechanism.
Is this inconsistency between result states somehow intended? (Recall, the
pipeline mode does call this an aborted build right away) Or am I
misinterpreting the build result concept in Jenkins?
Thanks, Philipp
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/CAHZz-hyeWKEPktzmeKgG0Rq88syd0rmdEAiB8Kawk9pzbZVYmg%40mail.gmail.com.