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

Viewed 24584

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...
        }
        ...
    }
    ...
}
...
5 Answers

Following checkout config works perfect for me in a jenkins pipeline script. We are using stash1 just like github as internal git server. Replace it with your own.

stage('Checkout') {
            steps {
                echo "Running checkout stage"
                checkout([$class: 'GitSCM', branches: [
                    [name: "*/${params.branch}"]
                ], doGenerateSubmoduleConfigurations: false, extensions: [
                    [$class: 'CleanCheckout'], [$class: 'CloneOption', timeout: 30, shallow: true]
                ], submoduleCfg: [], userRemoteConfigs: [
                    [credentialsId: 'ink_bot', url: "ssh://git@stash1.XYZ.com:7999/int_sparktp/${params.repo}.git"]
                ]])
            }
        }

Adding this extension works for me.

extensions: [[$class: 'CloneOption', timeout: 60]]
Related