2

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?

Wojtas.Zet
  • 636
  • 2
  • 10
  • 30

1 Answers1

3

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

ymochurad
  • 941
  • 7
  • 15
  • It actually works. So it solves the question. I have hit another issue though - If I use skipDefaultCheckout(), and then checkout([$class: 'GitSCM',]) to do it myself, I have: fatal: not a git repository (or any of the parent directories): .git – Wojtas.Zet Dec 20 '21 at 12:41