Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

jenkins - SparseCheckout in Jenkinsfile pipeline

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

   checkout([$class: 'GitSCM', 
       branches: [[name: '*/branchName']],
       extensions: [[$class: 'SparseCheckoutPaths', path: 'FolderName']],
       userRemoteConfigs: [[credentialsId: 'someID',
       url: '[email protected]']]])
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...