How do I implement a retry option for failed stages in Jenkins pipelines?

后端 未结 3 2039
深忆病人
深忆病人 2021-01-30 02:13

I have a Jenkinsfile with multiple stages and one of them is in fact another job (the deploy one) which can fail in some cases.

I know that I can made prompts using Jenk

3条回答
  •  日久生厌
    2021-01-30 02:58

    This one with a nice incremental wait

    stage('deploy-test') {
     def retryAttempt = 0
     retry(2) {
        if (retryAttempt > 0) {
           sleep(1000 * 2 + 2000 * retryAttempt)
        }
    
        retryAttempt = retryAttempt + 1
        input "Retry the job ?"
        build 'yourJob'
     }
    }
    

提交回复
热议问题