How to specify Job DSL checkout timeout in Jenkins Git plugin?

Petr Vepřek picture Petr Vepřek · Mar 9, 2016 · Viewed 19.8k times · Source

Clone timeout can be specified using:

git {
    ...
    cloneTimeout(60)
}

where 60 is timeout is minutes. I read that checkout timeout can also be specified but I cannot find details. Both checkoutTimeout(...) and timeout(...) give an error.

EDIT

I can set the checkout timeout via Jenkins GUI (Configuration --> SCM --> Git --> Additional Behaviors --> Advanced Checkout Behaviors --> Timeout). I'd like to do the same in a Groovy script that generates Docker configurations for Jenkins:

...
public class DockerJob {
...
    multiscm {
        git {
            remote {
                url(...)
                branch(...)
                ...
            }
            shallowClone()
            cloneTimeout(60)
            // Add "checkout timeout" here...
        }
        ...
    }
    ...
}
...

Answer

guillem picture guillem · Aug 30, 2017

I had to change it like this with the pipeline as the CheckoutOption was not working for me

extensions: [[$class: 'CloneOption', timeout: 120]]

Full checkout code

checkout([$class: 'GitSCM', branches: [[name: '*/master']],
            extensions: [[$class: 'CloneOption', timeout: 120]], gitTool: 'Default', 
            userRemoteConfigs: [[credentialsId: key, url: repo]]
        ])