Here comes the answer to my own question. For a bit of background how does it work, there is flag/configuration for git client called sparsecheckout which is responsible for this kind of checkout. Additionally, a sparse-checkout named file is also required. For more info look here.
My problem was the syntax for the Jenkinsfile and correct one is as follows:
checkout([$class: 'GitSCM',
branches: [[name: '*/branchName']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'SparseCheckoutPaths', sparseCheckoutPaths:[[$class:'SparseCheckoutPath', path:'folderName/']]]
],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'someID',
url: '[email protected]']]])
for more info, here comes the github-link
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…