2017-07-11 15:12:03 +02:00
|
|
|
# handlePipelineStepErrors
|
|
|
|
|
|
|
|
## Description
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
Used by other steps to make error analysis easier. Lists parameters and other data available to the step in which the error occurs.
|
|
|
|
|
|
|
|
## Prerequisites
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
none
|
|
|
|
|
|
|
|
## Parameters
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
| parameter | mandatory | default | possible values |
|
|
|
|
| -----------------|-----------|---------|-----------------|
|
|
|
|
| `stepParameters` | yes | | |
|
|
|
|
| `stepName` | yes | | |
|
|
|
|
| `echoDetails` | yes | true | true, false |
|
|
|
|
|
|
|
|
* `stepParameters` - The parameters from the step to be executed. The list of parameters is then shown in the console output.
|
|
|
|
* `stepName` - The name of the step executed to be shown in the console output.
|
2017-11-24 16:59:34 +02:00
|
|
|
* `echoDetails` - If set to true the following will be output to the console:
|
2019-02-21 16:46:17 +02:00
|
|
|
1. Step beginning: `--- Begin library step: ${stepName}.groovy ---`
|
|
|
|
2. Step end: `--- End library step: ${stepName}.groovy ---`
|
2018-11-06 14:50:09 +02:00
|
|
|
3. Step errors:
|
|
|
|
|
|
|
|
```log
|
2017-07-11 15:12:03 +02:00
|
|
|
----------------------------------------------------------
|
2019-02-21 16:46:17 +02:00
|
|
|
--- An error occurred in the library step: ${stepName}
|
2017-07-11 15:12:03 +02:00
|
|
|
----------------------------------------------------------
|
2019-02-21 16:46:17 +02:00
|
|
|
The following parameters were available to the step:
|
2017-07-11 15:12:03 +02:00
|
|
|
***
|
|
|
|
${stepParameters}
|
|
|
|
***
|
2019-02-21 16:46:17 +02:00
|
|
|
The error was:
|
2017-07-11 15:12:03 +02:00
|
|
|
***
|
|
|
|
${err}
|
|
|
|
***
|
2019-02-21 16:46:17 +02:00
|
|
|
Further information:
|
2017-07-11 15:12:03 +02:00
|
|
|
* Documentation of step ${stepName}: .../${stepName}/
|
|
|
|
* Pipeline documentation: https://...
|
|
|
|
* GitHub repository for pipeline steps: https://...
|
|
|
|
----------------------------------------------------------
|
|
|
|
```
|
|
|
|
|
2018-03-06 14:43:53 +02:00
|
|
|
## Step configuration
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2018-03-06 14:43:53 +02:00
|
|
|
none
|
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
## Side effects
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
none
|
|
|
|
|
|
|
|
## Exceptions
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
none
|
|
|
|
|
|
|
|
## Example
|
2018-11-06 14:50:09 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
```groovy
|
|
|
|
handlePipelineStepErrors (stepName: 'executeHealthCheck', stepParameters: parameters) {
|
|
|
|
def url = new Utils().getMandatoryParameter(parameters, 'url', null)
|
|
|
|
def statusCode = curl(url)
|
|
|
|
if (statusCode != '200')
|
|
|
|
error "Health Check failed: ${statusCode}"
|
|
|
|
}
|
|
|
|
```
|