7
votes

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?

1
Your understanding of a folder-level shared library is incorrect. A shared library is (currently) organized in this directory structure and can be loaded using @Library or the other supporting APIs (like library step). Maybe you are looking for the load step to use scripts in the same repository? It depends on what you are trying to accomplish. - mkobit
Thank you for your answer. Right now I just try to understand what a folder-level-shared library is. From the documentation it's not getting clear to me. Where do I register this library? Where/When do I use it? How do I use it? - Yannic Klem
I hope most of your questions will be answered by this section of documentation. - mkobit
Or some of the other parts that show you how to configure and setup the library before using it. - mkobit

1 Answers

4
votes

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 the using @Library if you choose not to load implicitely.

Differences are:

  • You define the library to use in the settings of a Jenkins folder
  • They are not trusted (as written in the link posted in the comments)

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