How to enable timeout in pipeline based on a condition?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to enable timeout in pipeline based on a condition?

Gajanan Mahajan
I've a Jenkins pipeline with following stage -

    stage('Test') {
                options {
                    timeout(time: 5, unit: 'MINUTES')
                }
                steps {
                    script {
                        //some code here
                    }
                }
            }

Here I've set timeout but there will be one parameter say `TimeoutEnabled`. If it has value `true`, only then use timeout restrictions otherwise there will be no timeout restriction for the stage.

How can I handle this efficiently without having duplicated code?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ee3e7588-dba4-41cf-8cec-2d331d0822d7o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

How to enable timeout in pipeline based on a condition?

James Nord-2
something like

'timeout(time: ${timeoutEnabled ? 5 : 9999}, unit: 'MINUTES')

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f2be1ff8-826f-4459-9f4b-d0f682c6d58bo%40googlegroups.com.