-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Jenkins Administrator's Guide
By :

As we start to use Groovy code to write the pipeline logic, it's inevitable that we'll end up repeating the same code across multiple pipelines. As programmers, we naturally look for ways to write functions, classes, and methods to organize repeated code. Shared libraries provide a way to encapsulate the repeated code and create helper functions, but that is only the beginning of what shared libraries can do.
The power of shared libraries is twofold. The first half of the chapter will show that there are two different ways of providing a shared library and four or five different ways of using a shared library7. Each of these options comes with slightly different capabilities, and this variety makes shared libraries useful in any Jenkins or pipeline configuration.
The second half of the chapter will show the different ways of using shared libraries. Exploring a commonly encountered scenario, we will write a global variable with helper functions...