mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-20 05:19:40 +02:00
Don't check for isResilient, use failOnError
This commit is contained in:
parent
4420c34e4f
commit
942e6dd18a
@ -8,8 +8,8 @@ The log was generated at: `$utcTimestamp UTC`
|
||||
|
||||
<% print failedBuild ? "## Unsuccessful Build" : "" %>
|
||||
|
||||
<% print failedBuild ? "#### Failed Stage" : "" %>
|
||||
<% print failedBuild.get("stage") ? "`${failedBuild.get("stage")}`" : "" %>
|
||||
<% print failedBuild ? "#### Failed Step" : "" %>
|
||||
<% print failedBuild.get("step") ? "`${failedBuild.get("step")}`" : "" %>
|
||||
|
||||
<% print failedBuild.get("reason") ? "#### Error Message" : "" %>
|
||||
<% print failedBuild.get("reason") ? "```\n${failedBuild.get("reason")}\n```" : "" %>
|
||||
@ -17,6 +17,7 @@ The log was generated at: `$utcTimestamp UTC`
|
||||
<% print failedBuild.get("stack_trace") ? "```" : "" %>
|
||||
<% print failedBuild.get("stack_trace").collect({each -> "${each}"}).join("\n") %>
|
||||
<% print failedBuild.get("stack_trace") ? "```" : "" %>
|
||||
<% print failedBuild.get("fatal") ? "#### Failure was fatal." : "" %>
|
||||
|
||||
## Pipeline Environment
|
||||
|
||||
|
@ -79,18 +79,16 @@ class DebugReport {
|
||||
*
|
||||
* @param stepName The name of the crashed step or stage
|
||||
* @param err The Throwable that was thrown
|
||||
* @param isResilientAndNotMandatory
|
||||
* Whether the step configuration indicated that this as
|
||||
* "resilient" step which is not included in the list of mandatory steps.
|
||||
* @param failedOnError Whether the failure was deemed fatal at the time of calling this method.
|
||||
*/
|
||||
void storeStepFailure(String stepName, Throwable err, boolean isResilientAndNotMandatory) {
|
||||
failedBuild.put('stage', stepName)
|
||||
void storeStepFailure(String stepName, Throwable err, boolean failedOnError) {
|
||||
failedBuild.put('step', stepName)
|
||||
failedBuild.put('reason', err)
|
||||
failedBuild.put('stack_trace', err.getStackTrace())
|
||||
if (isResilientAndNotMandatory) {
|
||||
failedBuild.put('isResilient', 'true')
|
||||
if (failedOnError) {
|
||||
failedBuild.put('fatal', 'true')
|
||||
} else {
|
||||
failedBuild.remove('isResilient')
|
||||
failedBuild.remove('fatal')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,10 @@ void call(Map parameters = [:], body) {
|
||||
message += formatErrorMessage(config, ex)
|
||||
writeErrorToInfluxData(config, ex)
|
||||
|
||||
boolean isMandatory = config.stepName in config.mandatorySteps
|
||||
DebugReport.instance.storeStepFailure(config.stepName, ex, config.isResilient && !isMandatory)
|
||||
boolean failOnError = config.failOnError || config.stepName in config.mandatorySteps
|
||||
DebugReport.instance.storeStepFailure(config.stepName, ex, failOnError)
|
||||
|
||||
if (config.failOnError || isMandatory) {
|
||||
if (failOnError) {
|
||||
throw ex
|
||||
}
|
||||
|
||||
@ -107,13 +107,12 @@ void call(Map parameters = [:], body) {
|
||||
cpe?.setValue('unstableSteps', unstableSteps)
|
||||
|
||||
} catch (Throwable error) {
|
||||
|
||||
boolean isMandatory = config.stepName in config.mandatorySteps
|
||||
DebugReport.instance.storeStepFailure(config.stepName, error, config.isResilient && !isMandatory)
|
||||
|
||||
if (config.echoDetails)
|
||||
message += formatErrorMessage(config, error)
|
||||
writeErrorToInfluxData(config, error)
|
||||
|
||||
DebugReport.instance.storeStepFailure(config.stepName, error, true)
|
||||
|
||||
throw error
|
||||
} finally {
|
||||
if (config.echoDetails)
|
||||
|
Loading…
x
Reference in New Issue
Block a user