1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/steps/handlePipelineStepErrors.md

53 lines
1.3 KiB
Markdown
Raw Normal View History

# ${docGenStepName}
2017-07-11 15:12:03 +02:00
## ${docGenDescription}
2017-07-11 15:12:03 +02:00
## Prerequisites
2017-07-11 15:12:03 +02:00
none
2019-04-04 10:50:46 +02:00
## ${docGenParameters}
## ${docGenConfiguration}
## ${docJenkinsPluginDependencies}
2019-05-24 15:41:49 +02:00
2017-07-11 15:12:03 +02:00
## Example
2017-07-11 15:12:03 +02:00
```groovy
handlePipelineStepErrors (stepName: 'executeHealthCheck', stepParameters: parameters) {
// The code you want to get controlled by the error handler goes right here into the closure
2017-07-11 15:12:03 +02:00
def url = new Utils().getMandatoryParameter(parameters, 'url', null)
def statusCode = curl(url)
if (statusCode != '200')
2019-04-04 10:50:46 +02:00
error "Health Check failed: \${statusCode}"
2017-07-11 15:12:03 +02:00
}
```
2019-04-03 13:16:38 +02:00
## Example console output
If `echoDetails` is set to true the following information will be output to the console:
2019-04-04 17:01:30 +02:00
1. Step beginning: `--- Begin library step: \${stepName}.groovy ---`
1. Step end: `--- End library step: \${stepName}.groovy ---`
2019-04-03 13:16:38 +02:00
1. Step errors:
```log
----------------------------------------------------------
2019-04-04 17:01:30 +02:00
--- An error occurred in the library step: \${stepName}
2019-04-03 13:16:38 +02:00
----------------------------------------------------------
The following parameters were available to the step:
***
2019-04-04 10:50:46 +02:00
\${stepParameters}
2019-04-03 13:16:38 +02:00
***
The error was:
***
2019-04-04 10:50:46 +02:00
\${err}
2019-04-03 13:16:38 +02:00
***
Further information:
2019-04-04 10:50:46 +02:00
* Documentation of step \${stepName}: .../\${stepName}/
2019-04-03 13:16:38 +02:00
* Pipeline documentation: https://...
* GitHub repository for pipeline steps: https://...
----------------------------------------------------------
```