How to clone a directory from a remote repo in a Jenkins pipeline script?

Viewed 11889

I have a large repo in GitHub Enterprise and need to clone a sub-directory from it on my Jenkins build server and just build that sub-directory. I am using a pipeline script and have this right now:

node {
    stage ('checkout') {
        git url: 'git@github.devops.mycompany.local:Org/MyLargeRepo.git'
    }
}

What I want is to clone from github.devops.mycompany.local:Org/MyLargeRepo/path/to/subproject

I know I probably need to use sparse checkouts, but can't seem to work out how to configure that in a Jenkins pipeline script. Any ideas?

1 Answers
Related