Reuse for Jenkinss
Jenkins reuse is about sharing pipeline logic across many projects, mainly through Shared Libraries. A shared library is a Git repository of Groovy code with a vars directory for global steps, loaded with the @Library annotation. It belongs to the Pipelines in Practice stage and avoids copying the same Jenkinsfile snippets.
Stage: Pipelines in Practice · Part of the Jenkins roadmap · Last reviewed 19 November 2026
What to learn in Reuse
- Create a shared library repository with a vars folder and a custom step
- Register the library in Jenkins and load it with @Library
- Pass parameters into a library step to customise behaviour
- Version a library using Git tags and pin pipelines to a version
- Decide what belongs in a library versus in a single Jenkinsfile
Reuse interview questions
Why use a Shared Library in Jenkins?
A Shared Library lets many repositories call the same tested steps, such as build, scan or deploy, instead of copying code. Changes are made once, versioned in Git and rolled out consistently. It keeps individual Jenkinsfiles short and standard.
How do you pin a Jenkins pipeline to a specific library version?
Reference the library with a version after the at sign, for example @Library('[email protected]'), where the version is a branch, tag or commit. Pinning prevents a change in the library from unexpectedly breaking every pipeline at once.
Where Reuse fits in the Jenkins roadmap
Reuse belongs to the Pipelines in Practice stage (intermediate level). Real workflows.
Other units in this stage
Back to the full Jenkins roadmap