How to Customize Checkout for Pipeline Multibranch? Bee Bot July 13, 2022 11:18 Updated The content of this article has moved to the new documentation site. Related articles Why is my multibranch project cloning the whole repository on the controller? How to access Changelogs in a Pipeline Job? Pipeline - Equivalent to Git Publisher How To Specify A Specific JDK In Pipeline? GitHub: Webhook Troubleshooting Comments 11 comments Sort by Date Votes Giorgio Sironi January 24, 2017 10:05 Interesting to see how this can be done with pipeline code (which is not very clear at https://jenkins.io/doc/pipeline/steps/workflow-scm-step/#checkout-general-scm). It seems however we are replicating information about the build configuration inside the pipeline definition, replicating attributes like: userRemoteConfigs: scm.userRemoteConfigs Is there a way to just specify what changes, altering the scm object or making a full copy of it with some customization? 0 Rbabzba 123 April 08, 2017 10:49 Edited I was trying to achieve the SparseCheckout but failing so far, your help would be highly appreciated. It checkout the whole branch instead of specified folder. checkout([ $class: 'GitSCM', branches:[[name: '*/branchName']], extensions: scm.extensions + [[$class: 'SparseCheckoutPaths'], path:'FolderName'], userRemoteConfigs: scm.userRemoteConfigs ]) 0 Viacheslav Dubrovskyi May 11, 2017 16:56 Hi.I would like use reference repository with credential. For example from Google Cloud source. Is it possible? Help me please. 0 Christian Schulz August 21, 2017 06:55 Not all additional behaviors seems to be supported. 0 Denys Digtiar August 21, 2017 23:21 Hi Christian, Your comment cannot really be addressed since it lacks any context and information about your environment. If you are CloudBees customer feel free to raise a support ticket, if not please approach the Jenkins community on regular channels (e.g. IRC, user mailing list, Stack Overflow). 0 Patrick Callahan January 31, 2018 00:45 I would like to do something like this because I would rather encode as much information about how the build is to be done in the Jenkinsfile as possible-- the only thing I really want to specify in the job itself is the location of the repository.My concern is not branch-specific behavior, but certain behaviors (like checking out to a local branch) that we'll need for all of our projects because our build tools expect it.Is it still considered a 'workaround' to be 'avoided' in my case? Should I prefer configuring the SCM through the web interface, for some reason? Is it 'not safe' to access the properties of the `scm` variable in this way? 0 Allan Burdajewicz February 05, 2018 00:39 Patrick, Since GitHub Branch Source 2.2.0 / Bitbucket Branch Source 2.2.0, such advanced behaviors - now known as SCM Traits are configurable at the organization / multibranch level in the UI. You should not need to fiddle with the checkout step anymore. 0 Patrick Callahan February 06, 2018 19:32 Thanks, Allan.I understand that these things can be configured one-by-one, in the UI. But copying and pasting a template Jenkinsfile for a new project is less manual and less error-prone, which is why I'd rather have that in the instructions for my organization than a bunch of directions about what to click on.Is there any reason that using this method is actually bad? (And is there any way to get the GitHub plugin, for example, to use 'Checkout via SSH' declaratively?) 0 Christian Polzer March 09, 2018 10:25 Hi there, Great article, thank you! This is also working for declarative pipeline? I am currently porting a regular "old" jenkinsfile to declarative syntax and suddenly my "maven release " step is not working anymore. It is triggered in case master branch is build. Thanks in advance! 0 Allan Burdajewicz March 12, 2018 09:02 Hi Christian, Yes. This is working with Declarative pipeline too. 0 Thomas Grainger April 24, 2019 09:43 I get: WorkflowScript: 10: Invalid config option "checkout" for agent type "node". Valid config options are [label, customWorkspace] @ line 10, column 13. checkout([ Also I notice that the issue mentioned in this post is now fixed: https://issues.jenkins-ci.org/browse/JENKINS-37658 0 Please sign in to leave a comment.