lartkma
lartkma

Reputation: 589

In Parametrized Trigger Plugin, what's the difference between "Fail this build step" and "Mark this build as failure"?

I'm checking a job that uses the Parametrized Trigger Plugin to call other projects. There are two options that I'm trying to understand: Fail this build step if the triggered build is worse or equal to and Mark this build as failure if the triggered build is worse or equal to. There is documentation available in-place but I don't understand it as well.

  • Fail this build step if the triggered build is worse or equal to: This option takes precedence over the two following ones if its value is not never. In that case, the result of the current build step (that is, success or failure) is based on the result of the triggered builds. If the condition defined for at least one of the triggered build is met, then the build step will be considered as failed.
  • Mark this build as failure if the triggered build is worse or equal to: This option takes precedence over the next one if its value is not set to never. In that case, the current build will be considered as failed based on the result of the triggered builds and the value of the option.

*The third option that is implied the documentation is "Mark this build as unstable if the triggered build is worse or equal to", that I'm imagining it works the same as the second option

What's the practical difference between "build step failed" and "build failed" here? Does the first implies that the step 'fails' and the build is 'failed' but the build continues its execution? And the second sets the build as 'failed' and then stops? What happens with the 'unstable' version, as I understood that the 'unstable' status usually doesn't stop the build?

Upvotes: 1

Views: 316

Answers (1)

Noam Helmer
Noam Helmer

Reputation: 6824

The difference between the two options is indeed the behavior of the failure type in the case the triggered build has failed. This two option allow to change the default behavior when a build step has failed. I will try to explain the behavior based on the Source Code of the plugin's perform method.

Each builder plugin (which will be exposed as a build step) has a perform method that will be called when the plugin's build step is executed. To signal a failure this method can throw an exception or return false - this will notify the executer that the step has failed so it will stop executing any further build steps and mark the build result as FAILURE. However, the perform function can also set the build result directly and return true - thus notifying the executer there where no fails while still setting the build result to the desired value.

Now lets examine the case a of this plugin (when you configure the options to FAILURE):

  • When you choose Fail this build step if the triggered build is worse or equal to it will cause the perform method to return false, thus notifying the executer the step is failed, so execution will stop, further build steps will not be executed and the build result will be marked as FAILURE.
    In the console output you will see something like:

Build step 'Trigger/call builds on other projects' marked build as failure

  • When you choose Mark this build as failure if the triggered build is worse or equal to it will cause the perform method to set the build result using build.setResult(r); but the returned value will be true, so execution will not stop, further build steps will be executed but the build result will be marked as FAILURE.
    In the console output you will see something like:

Build step 'Trigger/call builds on other projects' changed build result to FAILURE

Regarding the 'unstable' version, like the second option, they both "Mark this build" - meaning they just set the build result and do not affect execution. In the case of 'UNSTABLE' result that is the default and only behavior as it never stops the execution and therefore there is no meaning for the 'UNSTABLE' result to have the first option.

TL;DR differences between the two options:
Fail this build step if the triggered build is worse or equal to: will fail the current running build step, stop all further build step executions and mark the build result as FAILURE.
Mark this build as failure if the triggered build is worse or equal to : will mark the build result as FAILURE, and continue to execute all following build steps.

Upvotes: 1

Related Questions