SparseCheckout in Jenkinsfile pipeline

前端 未结 3 1547
猫巷女王i
猫巷女王i 2020-12-09 20:34

In a jenkinsfile, I have specified the folderName through SparseCheckoutPaths which I want to checkout. But I am getting a whole branch checkout instead.

3条回答
  •  独厮守ぢ
    2020-12-09 21:11

    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: 'git@link.git']]])
    

    for more info, here comes the github-link

提交回复
热议问题