jenkinsjenkins-pipelinejenkins-shared-libraries

How to import folder-level shared libraries in jenkins pipeline


First my understanding of folder-level shared libraries: It's a groovy script I can place anywhere in the repository where I want it to use (i.e. where my Jenkinsfile will be).

If this is wrong please let me know.

My question: How can I include this library. For global libraries I can use @Library($libraryName) to import libraries I registered with a name as global library. But for folder-level libraries there is no name specified. How do I import them? Do I really have to specify the git repo like demonstrated in this answer?


Solution

  • Folder-level shared libraries work similar to global shared libraries.

    They also need a dedicated repository featuring the known layout (vars, src folders). And you need to load them using @Library(<name>) _ if you choose not to load implicitly.

    Differences are:

    Just open the settings of a Jenkins folder and you'll find the options.