[JIRA] (JENKINS-54735) Pipeline retry clause: optionally delay between retries

301 views
Skip to first unread message

smokris@softpixel.com (JIRA)

unread,
Nov 20, 2018, 12:25:01 PM11/20/18
to jenkinsc...@googlegroups.com
Steve Mokris created an issue
 
Jenkins / Improvement JENKINS-54735
Pipeline retry clause: optionally delay between retries
Issue Type: Improvement Improvement
Assignee: Unassigned
Components: workflow-basic-steps-plugin
Created: 2018-11-20 17:24
Labels: pipeline
Priority: Major Major
Reporter: Steve Mokris

I use a retry block to perform requests on a remote server that I don't control (e.g., Apple's Code Signing or Notarization service), and sometimes that remote server is offline.

Currently retry immediately retries upon failure, so when the remote server is offline for an extended period of time, my pipeline project quickly retries and then the build fails.

It would be nice to have the ability to make retry wait after each failure, with optional exponential backoff (doubling the wait time after each failure), to give these builds a greater chance of success.  For example:

retry(tries:5, waitSecondsBetweenFailures:30, doubleWaitTimeAfterEachFailure:true)

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

smokris@softpixel.com (JIRA)

unread,
Nov 20, 2018, 12:37:02 PM11/20/18
to jenkinsc...@googlegroups.com
Steve Mokris commented on Improvement JENKINS-54735
 
Re: Pipeline retry clause: optionally delay between retries

A workaround in the meantime:

    retry(5) {
        ret = sh returnStatus: true, script: 'some-failure-prone-script'
        if (ret) {
            sleep time: 30, unit: 'SECONDS'
            error 'some-failure-prone-script failed'
{{        }}}
{{    }}}
…but there's no way to know when we're on the last retry attempt (see JENKINS-49341), so it unnecessarily waits 30 seconds when the last retry attempt fails.

smokris@softpixel.com (JIRA)

unread,
Nov 20, 2018, 12:40:02 PM11/20/18
to jenkinsc...@googlegroups.com
Steve Mokris edited a comment on Improvement JENKINS-54735
A workaround in the meantime:

{ { code}
    retry(5) { }}
{{         ret = sh returnStatus: true, script: 'some-failure-prone-script' }}
{{         if (ret) { }}
{{             sleep time: 30, unit: 'SECONDS' }}
{{             error ' }}{{ some-failure-prone-script failed' }}
{{         } }}
{{     }

{code
} }
…but there's no way to know when we're on the last retry attempt (see JENKINS-49341), so it unnecessarily waits
30 seconds when after the last retry attempt fails.

adam.brousseau88@gmail.com (JIRA)

unread,
Mar 25, 2019, 5:49:02 PM3/25/19
to jenkinsc...@googlegroups.com

in response to the workaround, what about this...?

ret = false
retry(5) {
        if (ret) {
            sleep time: 30, unit: 'SECONDS'
        } else {
            ret = true
        }
        sh 'some-failure-prone-script'         
    }

asgeirn@java.net (JIRA)

unread,
May 3, 2019, 6:17:03 AM5/3/19
to jenkinsc...@googlegroups.com
asgeirn commented on Improvement JENKINS-54735

Here's a different approach:

timeout(10) {
waitUntil {
script

{ def r = sh returnStatus: true, script: 'command' return r == 0 }

}
}

This will retry for up to 10 minutes. `waitUntil` automatically adds delays between the attempts.

asgeirn@java.net (JIRA)

unread,
May 3, 2019, 6:18:02 AM5/3/19
to jenkinsc...@googlegroups.com
asgeirn edited a comment on Improvement JENKINS-54735

asgeirn@java.net (JIRA)

unread,
May 3, 2019, 6:18:03 AM5/3/19
to jenkinsc...@googlegroups.com

asgeirn@java.net (JIRA)

unread,
May 3, 2019, 6:19:02 AM5/3/19
to jenkinsc...@googlegroups.com
asgeirn edited a comment on Improvement JENKINS-54735
Here's a different approach:

{
{        
code:groovy}
        timeout(10) {
            waitUntil {
                script {
                    def r = sh returnStatus: true, script: 'command'
                    return r == 0
                }
            }
        }
{code } }

This will retry for up to 10 minutes.  `waitUntil` automatically adds delays between the attempts.

asgeirn@java.net (JIRA)

unread,
May 3, 2019, 6:20:02 AM5/3/19
to jenkinsc...@googlegroups.com

asgeirn@java.net (JIRA)

unread,
May 3, 2019, 6:20:03 AM5/3/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages