-
Bug
-
Resolution: Unresolved
-
Minor
-
Jenkins ver. 2.19.2
Pipeline 2.4
Pipeline: Multibranch 2.9
Ubuntu 16 LTS
Additional Behaviors > Check out to a sub-directory clones Jenkinsfile in the specified directory. Meanwhile, Jenkins itself continues to look for Jenkinsfile at the top of the workspace. This is very confusing.
As far as I can see, Additional Behaviors > Check out to a sub-directory is never appropriate with Pipeline. This should be handled in Jenkinsfile using dir():
dir('subDir') {
checkout scm
}
In JENKINS-40267, jglick suggested that git-plugin should conditionally display the Additional Behaviors > Check out to a sub-directory option only if the AncestorInPath is an AbstractProject.
Removing the option might break compatibility but we could print an explanatory warning into the build log. The warning would say that Check out to a sub-directory is not intended for use with Pipeline jobs. The message should describe the preferred declarative technique of using the the dir step to provide a subdirectory which contains the checkout or using the checkoutToSubdirectory option.
I believe your concern is that when using the UI to define the top level pipeline project (in a pipeline project that gets its Jenkinsfile from a git repository, or in a multi-branch pipeline), there are options displayed which will prevent the pipeline code from finding Jenkinsfile in the ...@script directory. I think you're right that we should disable presenting those options to the user when they are defining the top level pipeline project.
I think your statement:
is too broad, at least for my use case. I use checkout to a subdirectory to allow me to bring multiple repositories into a single workspace with simple calls to checkout. I could certainly replace those calls to checkout by nesting them inside a dir(), but I don't see why we should disallow my use of checkout to a subdirectory from inside a Jenkinsfile. I don't see how that would help users who (like me) can use "Pipeline Syntax" to show the options in that context, and use them.
Refer to the 35475 verification check Jenkinsfile for an example of how I use checkout to a subdirectory inside a Jenkinsfile.
However, I'm certainly open to further knowledge from jglick. I would rather not break compatibility with existing uses of the checkout command, unless there is a compelling reason to do so.