0

I have a git hub repository ABC.git it has the following directories src ,config,env, test. I just want to checkout the src and config folder into my Jenkins workspace.

I am able to checkout the complete repository into my jenkins workspace using the SCM plugin.

command used for checking out complete branch :

checkout([
        $class: 'GitSCM', 
        branches: [[name: '*/master']], 
        doGenerateSubmoduleConfigurations: false, 
        extensions: [[$class: 'CleanCheckout']], 
        submoduleCfg: [], 
        userRemoteConfigs: [[credentialsId: '<gitCredentials>', url: '<gitRepoURL>']]
    ])
shavasth
  • 13
  • 4

1 Answers1

0

Use this to checkout specific directory/subdirectory: extensions: [[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: '/directory/path/here']]]]

So your script will look like this:

checkout([
    $class: 'GitSCM',
    branches: [[name: '*/master']],
    doGenerateSubmoduleConfigurations: false, 
    extensions: [[$class: 'CleanCheckout'],
    [$class: 'SparseCheckoutPaths',
    sparseCheckoutPaths: [[path: '/directory/path/here']]]],
    submoduleCfg: [],
    userRemoteConfigs: [[credentialsId: '<gitCredentials>', url: '<gitRepoURL>']]
])
Jerakin
  • 455
  • 3
  • 17