Conditionally Skip Default Checkout

Howdy. I’m experiencing an issue where my controller branch of my pipeline fails to checkout in a certain step due to issues with submodule checkout.

fatal: destination path ‘/var/lib/jenkins/jenkins-agent-workdir/jenkins-agent-workdir/workspace/insert_name_here@3/source/nginx/public/lib/directory-name-here’ already exists and is not an empty directory.

I can alleviate this issue in the controller branch by configuring the pipeline step to skipDefaultCheckout(), but then my pull request builds end up failing because nothing is checked out.

I’m a little green with Jenkins and not sure how to proceed – could someone please explain where I’m going wrong?

Depending on how you’re checking out your project, in the build configuration you can add additional behaviours/actions for checkout. In this case you could try ignoring submodules under the advanced sub-modules behaviours option. This of course would most likely then skip ALL submodules. See below.