Is pipeline timeout suppose to work?

2,259 views
Skip to first unread message

jer...@bodycad.com

unread,
Jul 7, 2017, 3:46:17 PM7/7/17
to Jenkins Users

HI,
is the timeout can be used to prevent the warnings publisher and bat hang even possible?

stage('Build')
{
timeout(60)
{
bat returnStatus: false, script: "\"${bcad.msbuild_current}\" ${bcad.msbuild_solution_name} ${bcad.msbuild_default_arg} /t:Build"
step([$class: 'WarningsPublisher', canRunOnFailed: true, consoleParsers: [[parserName: 'MSBuild']]])
}
}


and it have hang for over 3 hours now :-(
I was hoping to at least be able to stop those nasty hanging build and make them failed but doesn't seem to work. maybe I'm using timeout wrongly or the default units is not min like the doc and example said???



Danny Rehelis

unread,
Jul 7, 2017, 3:59:30 PM7/7/17
to Jenkins Users

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8e24ad7b-cb94-4505-8819-e1592c4f2b49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jer...@bodycad.com

unread,
Jul 10, 2017, 9:33:16 AM7/10/17
to Jenkins Users
When trying the 45 minutes units into the syntax helper (pipeline-syntax/ of the project) it display the following code:
timeout(45) {
    // some block
}

If I change the unit the syntax change like follow:
timeout(time: 45, unit: 'SECONDS') {
    // some block
}

So I will try with the following too see if it change something:
timeout(time: 45, unit: 'MINUTES') {
    // some block
}

The document seem to specify the timeout goes into the options block when using declarative pipeline (which I don't), but for normal pipeline I guess the //some block above is for any code block or is a block a specific type (stage, node...) ? This is unclear.
If this is any code block, it doesn't seem to work with either bat or steps warning publisher, which I cannot interrupt by cancelling the build into the GUI, so I guess the timeout may not cancel them either.

Jakub Pawlinski

unread,
Jul 11, 2017, 5:31:08 AM7/11/17
to Jenkins Users
I use this on pipeline level and it works fine there, haven't tried on stage level tho.

pipeline {
options {
timeout(time: 12, unit: 'HOURS')
timestamps()
}
...
}

jer...@bodycad.com

unread,
Jul 11, 2017, 4:57:44 PM7/11/17
to Jenkins Users
This is Declarative pipeline syntax (which I don't use), for non Declarative pipeline (which is what I have), I wonder if this work the same or where it can be used?

jer...@bodycad.com

unread,
Jul 12, 2017, 10:55:33 AM7/12/17
to Jenkins Users
I think I got my answer about it into the console log after a hang, I had to restart the jenkins service and got this as a result:

04:18:53 
04:18:53 Build succeeded.
04:18:53     0 Warning(s)
04:18:53     0 Error(s)
04:18:53
04:18:53 Time Elapsed 00:14:25.77
Waiting to resume part of Bodycad cpp projects » CAD_CPP_ContinuousBuild #172: JGMachine is offline
Waiting to resume part of Bodycad cpp projects » CAD_CPP_ContinuousBuild #172: JGMachine is offline
Ready to run at Wed Jul 12 10:50:34 EDT 2017
10:50:34 Timeout expired 5 hr 46 min ago
10:50:34 Cancelling nested steps due to timeout
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] echo
Error occurred during build:
[Pipeline] echo
java.lang.Exception: Resume after a restart not supported for non-blocking synchronous steps

the line: 
10:50:34 Timeout expired 5 hr 46 min ago
tell me that it cannot be used that way.

Kevin Chow

unread,
Apr 10, 2019, 5:27:36 PM4/10/19
to Jenkins Users
Hi Jer,

I'd like to followup if you figured out how to do timeout with Jenkins Scripted Pipeline. I'm looking into a solution to resolve it. 

I have something like but it doesn't work out for me.

timeout(5) {
node
("docker") {
sh
"""
//do something
"""

}
}



Thanks,

Kevin

Reinhold Füreder

unread,
Apr 11, 2019, 3:37:00 AM4/11/19
to jenkins...@googlegroups.com

Hi Kevin,

 

I have used “timeout” step in the past and as far as I can remember it worked as expected.

 

Note, however, that I may not have put the “node(…)” step inside the “timeout” step; not sure if that is of any relevance though…

 

HTH Reinhold

Reply all
Reply to author
Forward
0 new messages