How to clone a directory from a remote repo in a Jenkins pipeline script?
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:
What I want is to clone from
- Use a lightweight executor for a declarative pipeline stage (agent none)
- How to obtain the folder where the Pipeline Jenkinsfile is checked out (Jenkins)
- Jenkins Pipeline - SVN polling
- How to get scm url in build script for jenkins multibranch workflow project
- How to trigger a jenkins build on specific node using pipeline plugin?
- How do I use Jenkins Pipeline properties step?
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?
One Solution collect form web for “How to clone a directory from a remote repo in a Jenkins pipeline script?”
That looks like declarative pipeline, and not scripted pipeline
With the latter, you can use the syntax seen in this answer, based on the
hudson.plugins.git.extensions.impl.SparseCheckoutPaths class from The Jenkins Git Plugin:
checkout([$class: 'GitSCM', branches: [[name: '*/branchName']], doGenerateSubmoduleConfigurations: false, extensions: [ [$class: 'SparseCheckoutPaths', sparseCheckoutPaths:[[$class:'SparseCheckoutPath', path:'folderName/']]] ], submoduleCfg: , userRemoteConfigs: [[credentialsId: 'someID', url: 'firstname.lastname@example.org']]])
Don’t forget the