As far as I know, there isn't a way to avoid multiple fetches with the
current git plugin and git client plugin implementation.

It should be feasible to eventually remove at least one of the duplicate
fetches so long as the job has configured the checkout option to use the
same refspec in the initial fetch as is used in the checkout.  Refer to
"Honor refspec on initial clone" at
https://plugins.jenkins.io/git#clone-extensions .  Unfortunately, that is a
"feasible" idea but not an implemented idea.  The duplicate fetch is
performed in all job types, even Freestyle.  Thus, it may be even later
than the cases you're trying to handle with multibranch pipeline.

Reference repositories, narrow refspecs, and shallow clone are the current
alternatives to reduce the clone time and disc space for a git workspace.
Refer to
https://www.slideshare.net/markewaite/git-for-jenkins-faster-and-better for
slides that I presented at Jenkins World 2019 on those alternatives.  Refer
to
https://support.cloudbees.com/hc/en-us/articles/115001728812-Using-a-Git-reference-repository
for
a deeper dive into the technique.  Refer to https://youtu.be/jBGFjFc6Jf8
and https://youtu.be/TsWkZLLU-s4?t=139 for older video descriptions of the
techniques.

On Mon, Dec 16, 2019 at 7:37 PM Tim Black <timbla...@gmail.com> wrote:

> Is there ANY multibranch pipeline configuration that would allow me to:
> * place a Jenkinsfile at single BranchSource repo root, and
> * perform A SINGLE FETCH of this repo, full stop, and
> * fetch --tags in this single fetch, and
> * all of the above works when either "WipeWorkspace" or
> "CleanBeforeCheckout" traits are set, so that the initial fetch (tags and
> all) are preserved without having to fetch --tags again
> ??
>
> I have a multibranch pipeline project configured with a single
> BranchSource pointing at my repo containing Jenkinsfile. I have set the
> following BranchSource traits in config.xml:
>
>               <jenkins.plugins.git.traits.BranchDiscoveryTrait/>
>               <jenkins.plugins.git.traits.TagDiscoveryTrait/>
>               <jenkins.plugins.git.traits.SubmoduleOptionTrait>
>                 <extension class=
> "hudson.plugins.git.extensions.impl.SubmoduleOption">
>                   <disableSubmodules>false</disableSubmodules>
>                   <recursiveSubmodules>true</recursiveSubmodules>
>                   <trackingSubmodules>false</trackingSubmodules>
>                   <reference></reference>
>                   <parentCredentials>false</parentCredentials>
>                   <shallow>false</shallow>
>                 </extension>
>               </jenkins.plugins.git.traits.SubmoduleOptionTrait>
>               <jenkins.plugins.git.traits.CleanBeforeCheckoutTrait>
>                 <extension class=
> "hudson.plugins.git.extensions.impl.CleanBeforeCheckout"/>
>               </jenkins.plugins.git.traits.CleanBeforeCheckoutTrait>
>
> trying to coerce the project to fetch the repo ONCE to obtain everything
> my pipeline needs. (I have also tried this with "WipeWorkspaceTrait" and I
> get same problem.)
>
> What is happening is that I can configure the project to fetch tags but
> it's meaningless if I have either "WipeWorkspaceTrait"
> or "CleanBeforeCheckoutTrait" set. This is because both of these delete the
> tags in the working tree. The first fetch is obviously there for grabbing
> the Jenkinsfile, but I don't understand why it needs to wipe/clean AFTER
> that. Why do the "WipeWorkspaceTrait" or "CleanBeforeCheckoutTrait" have
> to be implemented AFTER the initial fetch?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/8e9b12ca-ac47-4da9-977f-99da4b88b255%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/8e9b12ca-ac47-4da9-977f-99da4b88b255%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks!
Mark Waite

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGMTFXqDGoLP-aQpMgY2ATfHQoRzUZn%2BFqjueUuy6YFtQ%40mail.gmail.com.

Reply via email to