Search code examples
jenkinsjenkins-pipelinejenkins-plugins

how to override default Jenkins Git plugin checkout with pipeline code?


I have jenkins multibranch pipeline with jenkins git plugin. When the new pull requested is created a new PR job starts, and checkout of the repository is done automatically. The problem is sometimes it hits timeout (networking).

I try to do retry in pipeline by using GitSCM code with some conditionals:

        checkout([
              $class: 'GitSCM',
              branches: scm.branches,
              doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
              extensions: scm.extensions + [[$class: 'CloneOption', noTags: false, reference: '', shallow: false]],
              submoduleCfg: [],
              userRemoteConfigs: scm.userRemoteConfigs
            ])
    }

It repeats the checkout just fine, but I still need to disable the first default checkout from the plugin(if it fails the job fails). How do I do that? How do I override the built-in checkout?


Solution

  • skipDefaultCheckout option should disable default checkout. E.g.:

    options { skipDefaultCheckout() }
    

    Read more here about it: https://www.jenkins.io/doc/book/pipeline/syntax/#available-options