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.
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).
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?
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.
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?)
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.
Comments
11 comments
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:
Is there a way to just specify what changes, altering the scm object or making a full copy of it with some customization?
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.
Hi.
I would like use reference repository with credential. For example from Google Cloud source. Is it possible? Help me please.
Not all additional behaviors seems to be supported.
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).
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?
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.
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?)
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!
Hi Christian,
Yes. This is working with Declarative pipeline too.
I get:
Also I notice that the issue mentioned in this post is now fixed: https://issues.jenkins-ci.org/browse/JENKINS-37658
Please sign in to leave a comment.