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/pipelineRestartSteps.md
Marcus Holl 7446b1e93d Remove return value from step documentation
In the meantime the steps do not have a return value anymore.
2018-11-09 16:09:29 +01:00

2.5 KiB

pipelineRestartSteps

Description

Support of restarting failed stages or steps in a pipeline is limited in Jenkins.

This has been documented in the Jenkins Jira issue JENKINS-33846.

For declarative pipelines there is a solution available which partially addresses this topic: https://jenkins.io/doc/book/pipeline/running-pipelines/#restart-from-a-stage.

Nonetheless, still features are missing, so it can't be used in all cases. The more complex Piper pipelines which share a state via commonPipelineEnvironment will for example not work with the standard restart-from-stage.

The step pipelineRestartSteps aims to address this gap and allows individual parts of a pipeline (e.g. a failed deployment) to be restarted.

This is done in a way that the pipeline waits for user input to restart the pipeline in case of a failure. In case this user input is not provided the pipeline stops after a timeout which can be configured.

Prerequisites

none

Example

Usage of pipeline step:

pipelineRestartSteps (script: this) {
  node {
    //your steps ...
  }
}

!!! caution Use node inside the step. If a node exists outside the step context, the input step which is triggered in the process will block a Jenkins executor.

In case you cannot use `node` inside this step, please choose the parameter `timeoutInSeconds` carefully!

Parameters

parameter mandatory default possible values
script yes
sendMail no true
timeoutInSeconds no 900

Details

  • script defines the global script environment of the Jenkinsfile run. Typically this is passed to this parameter. This allows the function to access the commonPipelineEnvironment for storing the measured duration.
  • If sendMail: true the step mailSendNotification will be triggered in case of an error
  • timeoutInSeconds defines the time period where the job waits for input. Default is 15 minutes. Once this time is passed the job enters state FAILED.

Step configuration

We recommend to define values of step parameters via config.yml file.

In following sections the configuration is possible:

parameter general step stage
script
sendMail X X X
timeoutInSeconds X X X

Side effects

none

Exceptions

none