Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 229
Yannic Klem Avatar asked Apr 30 '18 15:04

Yannic Klem


People also ask

How do I add a shared library in Jenkins?

In Jenkins, go to Manage Jenkins → Configure System. Under Global Pipeline Libraries, add a library with the following settings: Name: pipeline-library-demo. Default version: Specify a Git reference (branch or commit SHA), e.g. master.

What is a shared library file?

A shared library or shared object is a file that is intended to be shared by multiple programs. Symbols used by a program are loaded from shared libraries into memory at load time or runtime.


1 Answers

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.

like image 108
Joerg S Avatar answered Nov 04 '22 05:11

Joerg S