Re: SharedLibrary, clone, using resources

148 views
Skip to first unread message
Message has been deleted

itchymuzzle

unread,
Nov 3, 2017, 11:26:08 AM11/3/17
to Jenkins Users
Please post something which is readable.  Thanks.

Jakub Michalec

unread,
Nov 3, 2017, 12:03:59 PM11/3/17
to Jenkins Users


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? 

itchymuzzle

unread,
Nov 3, 2017, 12:37:04 PM11/3/17
to Jenkins Users
I have this same question.  

Mark Waite

unread,
Nov 3, 2017, 1:00:42 PM11/3/17
to jenkins...@googlegroups.com
On Fri, Nov 3, 2017 at 10:37 AM itchymuzzle <chris...@3derm.com> 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 jenkinsci-use...@googlegroups.com.
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.

jer...@bodycad.com

unread,
Nov 3, 2017, 1:06:25 PM11/3/17
to Jenkins Users
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.

itchymuzzle

unread,
Nov 6, 2017, 1:17:59 PM11/6/17
to Jenkins Users

Sounds a little related: 

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

Jakub Michalec

unread,
Nov 7, 2017, 9:35:53 AM11/7/17
to Jenkins Users
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 :)
Reply all
Reply to author
Forward
0 new messages