On Thu, Jul 30, 2020 at 12:07 PM Philipp Mahlberg <[email protected]> wrote: > Within a `run`-method of a step I can call run.setResult()
You _can_ but you _should not_. `setResult` should only ever be called by infrastructure code (in Jenkins core or Pipeline foundation plugins like `workflow-job`). (There is currently an exception carved out for `UNSTABLE` though it is better to use `WarningAction`.) > In case of an error that is still "normal" in terms that I might happen > during a build process but is such severe that I want to abort the build Let us say _fail_ the build. > I throw an Exception e.g. of type AbortException. Jenkins, in turn, marks > such builds as FAILED. Correct. > The other two possible outcomes, namely ABORTED or NOT_BUILD are beyond the > scope of "normal" build execution Well, `ABORTED` is pretty common; and `NOT_BUILT` is used occasionally for example from the `milestone` step to indicate that the build was not “aborted” per se, it just did not run some or all of its normal stages or whatever. > This would still leave an ambiguity between "failed, but completed" and > "normally aborted" (which gets also marked as failed) Perhaps you are misinterpreting. For Pipeline at least (traditional build types are mostly analogous): `FAILURE` means the build did not complete all of its expected operations: a “fatal error” in the Javadoc. For example, some `sh` step had a nonzero exit status and there was nothing catching that, so everything after that point was skipped. `AbortException` is an exception like any other, unwinding the call stack, with the sole difference that it suppresses printing a stack trace at the end because the failure is thought to be a user-level problem rather than an internal bug. If the Groovy program defined by a Pipeline script returned normally (execution reaches the end of the implicit `Script.run` method), then the build is by default `SUCCESS`, though it could be `UNSTABLE` if some nonfatal problems were recorded, such as test failures. `ABORTED` means a `FlowInterruptedException` terminated the script, either because the build as a whole was actually interrupted (e.g., user clicks red *X*) or because some step threw it and nobody caught it (e.g., `timeout` exceeded). A `FlowInterruptedException` may also set another result if desired, and it can include causes that get printed to the log and shows in the build summary. -- 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/CANfRfr0ean6fqbHyapjiHHh_ZzHUYqKn3xFRNZSVy37_U1iy%3Dw%40mail.gmail.com.
