What Is a Shared Library in Jenkins?

You have heard about shared libraries in the context of Jenkins Pipelines.  What is a Jenkins Pipeline shared library?

It is something that extends a Jenkins Pipeline (1).  A library is often composed of one or more of the following Roman numeral items (sources include (2) (3)):

  i.  Groovy-based DSL.
  ii. Groovy code and compiled programs.
  iii.  Java code and compiled programs.
  iv.  variables and other artifacts possibly in directories named /vars, /src, and /resources.  

There are three requirements for defining a shared library; these are a name, a code repository, and a version (1).  The version can refer to a branch in a Git repository (1).

One big benefit of using a shared library is that it makes other Jenkins Pipelines easier to maintain by keeping one group of common files, configuration settings and variables in one place (1).  Abstracting out the shared values and files you create an opportunity to have individual Jenkins Pipelines be of minimal sizes. (1)

The term shared library is used in the context of the C programming language.  To learn more about this see this link.

(1)  https://jenkins.io/doc/book/pipeline/shared-libraries/
(2)  https://medium.com/devopslinks/a-hacky-hackers-guide-to-jenkins-scripted-pipelines-part-4-dd49fcb0d62
(3)  https://automatingguy.com/2017/12/29/jenkins-pipelines-shared-libraries/

Leave a comment

Your email address will not be published. Required fields are marked *