[JIRA] (JENKINS-51454) Declarative pipeline retry operation doesn't retry when there is a timeout inside of it

2 views
Skip to first unread message

daconstenla@gmail.com (JIRA)

unread,
May 21, 2018, 6:49:02 AM5/21/18
to jenkinsc...@googlegroups.com
David Constenla created an issue
 
Jenkins / Bug JENKINS-51454
Declarative pipeline retry operation doesn't retry when there is a timeout inside of it
Issue Type: Bug Bug
Assignee: vjuranek
Components: groovy-plugin, pipeline
Created: 2018-05-21 10:48
Environment: jenkins: jenkins:2.123-alpine (running in docker)
Pipeline: Declarative: 1.2.9
Pipeline: Groovy: 2.53
Labels: timeout retry abort pipeline declarative
Priority: Minor Minor
Reporter: David Constenla

When a declarative timeout call is fired inside of a retry, retry is not being triggered and job execution is aborted, the only way to make it work is by surrounding the timeout operation with a try/catch.

without try/catch

Log output

Cancelling nested steps due to timeout

Execution result

Timeout has been exceeded
Finished: ABORTED

with try/catch

Log output

Timeout set to expire after 2 sec without activity
Sleeping for 2 sec
Cancelling nested steps due to timeout
ERROR: catched timeout! org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
Retrying

Execution result

Finished: SUCCESS

 

Examples to reproduce the issue

Failing example

node {
    def timeoutSeconds = 3
    stage('Preparation') { // for display purposes
        retry(3){
            timeout(activity: true, time: 2, unit: 'SECONDS') {
                sleep(timeoutSeconds)
            }
            timeoutSeconds--
        }
   }
}

Working example

node {
    def timeoutSeconds = 3
    stage('Preparation') { // for display purposes
        retry(3){
            try{
                timeout(activity: true, time: 2, unit: 'SECONDS') {
                    sleep(timeoutSeconds)
                }
            }catch(err){
                timeoutSeconds--
                script{
                  def user = err.getCauses()[0].getUser()
                  error "[${user}] catched timeout! $err"
                }
            }
        }
   }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

svanoort@cloudbees.com (JIRA)

unread,
May 21, 2018, 6:23:02 PM5/21/18
to jenkinsc...@googlegroups.com
Sam Van Oort updated an issue
Change By: Sam Van Oort
Component/s: pipeline-model-definition-plugin
Component/s: groovy-plugin
Component/s: pipeline

svanoort@cloudbees.com (JIRA)

unread,
May 21, 2018, 6:23:02 PM5/21/18
to jenkinsc...@googlegroups.com

svanoort@cloudbees.com (JIRA)

unread,
May 21, 2018, 6:23:03 PM5/21/18
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Nov 15, 2018, 12:11:02 PM11/15/18
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Labels: abort declarative pipeline retry timeout triaged-2018-11
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

nepomuk.seiler@gutefrage.net (JIRA)

unread,
Jan 22, 2019, 4:36:02 AM1/22/19
to jenkinsc...@googlegroups.com
Nepomuk Seiler commented on Bug JENKINS-51454
 
Re: Declarative pipeline retry operation doesn't retry when there is a timeout inside of it

It looks like the org.jenkinsci.plugins.workflow.steps.FlowInterruptedException exception could be the  cause. If the timeout directive would throw another exception, would this solve the issue?

lpiedra@gmail.com (JIRA)

unread,
Mar 28, 2019, 8:11:06 AM3/28/19
to jenkinsc...@googlegroups.com

If capturing the `FlowInterruptedException` it will retry also when aborting the job for any other reason, like canceling. Definitively, timeout should thow a different exception.

me@basilcrow.com (JIRA)

unread,
May 29, 2019, 6:32:03 PM5/29/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages