I have a Jenkins pipeline with the 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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.