SharedLibrary, clone, using resources

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

SharedLibrary, clone, using resources

Jakub Michalec

Hello,

I have question regarding SharedLibrary, I put some powershell script (/scripts/…) in same repository and I want to use them during builds.

 

Atm, I use it like this

 

@Library('JenkinsSharedLibrary') _

 

pipeline {

    agent { node { label 'azure' } }

 

    options {

        skipDefaultCheckout()

    }

   

    stages {

        stage('Clean Workspace') {

            steps {              

                deleteDir()

                checkout scm

            }

        }

 

        stage(....)

}

 

Thanks to that in workspace I get all scripts from repo, but jenkins job is cloning repo two times

  • First, to get Job from Repository (Pipeline from SCM)
  • Second, in checkout scm

 

In logs

 

Get job:

 

Obtained jobs/Cloud_Deployment/cloud_azure_polling.groovy from git http://git.***.jenkinssharedlibrary.git
Loading library JenkinsSharedLibrary@master

 

Clone Lib:

Cloning the remote Git repository
Cloning repository http://git.***./jenkinssharedlibrary.git

 

Is it possible to made it in one step?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9d0a6fd4-bd4b-44e5-b774-9a043fbc05fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

itchymuzzle
Please post something which is readable.  Thanks.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cc1a1fd3-d2c6-440c-b3be-642f1634dbc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

Jakub Michalec


W dniu piątek, 3 listopada 2017 16:26:08 UTC+1 użytkownik itchymuzzle napisał:
Please post something which is readable.  Thanks.

Hello,
I have question regarding SharedLibrary, I put some powershell script (/scripts/…) in same repository and I want to use them during builds.

Atm, I use it like this

@Library('JenkinsSharedLibrary') _


pipeline
{
    agent
{ node { label 'azure' } }


    options
{
        skipDefaultCheckout
()
   
}
   
    stages
{
        stage
('Clean Workspace') {
            steps
{              
                deleteDir
()
                checkout scm
           
}
       
}


        stage
(....)
}


Thanks to that in workspace I get all scripts from repo, but jenkins job is cloning repo two times
First, to get Job from Repository (Pipeline from SCM)
Second, in checkout scm

In logs

Get job:

Obtained jobs/Cloud_Deployment/cloud_azure_polling.groovy from git http://git.***.jenkinssharedlibrary.git
Loading library JenkinsSharedLibrary@master



Clone Lib:
Cloning the remote Git repository
Cloning repository http://git.***./jenkinssharedlibrary.git



Is it possible to made it in one step? 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/75356e13-9354-4f50-86c7-1570f9127f2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

itchymuzzle
In reply to this post by itchymuzzle
I have this same question.  

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c42cc35d-d081-4cf1-8435-bc96b9abf386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

Mark Waite-2


On Fri, Nov 3, 2017 at 10:37 AM itchymuzzle <[hidden email]> wrote:
I have this same question.  

I thought that the branch source plugins (GitHub, Gitea, and possibly Bitbucket) provide a technique to avoid the copy of the full repository to retrieve the Jenkinsfile.

However, if you're trying to avoid cloning the shared library repository, I'm not sure what that will gain, since the shared library repository needs to provide multiple files, not just the single Jenkinsfile.

I think it is wise to keep the size of the shared library repository small, containing only shared library components.  You don't want unrelated changes causing concern for the users of the shared library.

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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c42cc35d-d081-4cf1-8435-bc96b9abf386%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHuBLGgTt6nfJFVZ4hAoeVWNYn7yqNvPoweNzq4Bg2RxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

jerome-2
In reply to this post by Jakub Michalec
Jenkins checkout the Jenkinsfile first and then the scm inside the jenkins checkout. If you can, try to enable the Lightweight checkout on the jenkinsfile checkout.

Side note, I for one make a repos for the jenkins file that is not the same as the code repos, so my server and build setup evolve at different pace as the code and I can build old version into a recent configuration (jenkins updated and jenkinsfile needed to be modified for a while). I did more enjoy doing it this way then having my Jenkins file static into a revision of the source repos. I can also try different Jenkinsfile with the same source code Jenkinsfile checkout use build parameter.
Side note #2: I also use mercurial with sub repos, so my jenkinsfile pull subrepos for the shared scripts/lib/exe that I use during the build process, this work like a charm.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3bbb7e7e-f34b-47b6-9218-84dd8014a009%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

itchymuzzle
In reply to this post by Jakub Michalec

Sounds a little related: 

Provide lightweight checkout capability for bitbucket to avoid repo clone of rmulti-branch pipelinejobs link 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3a780803-e052-42c3-a7b8-e5cb471c13cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: SharedLibrary, clone, using resources

Jakub Michalec
I have a bit different scenario, I don't use Jenkinsfile in this jobs, they're more like 'utility' jobs eq Clean Azure Env etc.

So, I want to get pipeline groovy script which use Powershell in stages from folder scripts.

Also, I use Stash (atlassian git).

I decide to create new repo, just for Jenkins shared library, but still getting only scripts folder would made less noise :)


W dniu poniedziałek, 6 listopada 2017 19:17:59 UTC+1 użytkownik itchymuzzle napisał:

Sounds a little related: 

Provide lightweight checkout capability for bitbucket to avoid repo clone of rmulti-branch pipelinejobs <a href="https://issues.jenkins-ci.org/browse/JENKINS-42518" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-42518\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHOxkgtYPzBxMXKSj56OtsUXO4q0w&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-42518\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHOxkgtYPzBxMXKSj56OtsUXO4q0w&#39;;return true;">link 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3ba67f4c-0319-4caa-9011-aee247d50ccb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.