0
0
Jenkinsdevops~5 mins

Library versioning in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is library versioning in Jenkins pipelines?
Library versioning in Jenkins pipelines means specifying which version of a shared library your pipeline should use. This helps keep your builds stable and predictable.
Click to reveal answer
beginner
How do you specify a library version in a Jenkinsfile?
You specify a library version in a Jenkinsfile using the @Library annotation with the version name, like: <br>@Library('my-shared-lib@1.2.3') _
Click to reveal answer
intermediate
Why is it important to use specific library versions instead of 'latest' in Jenkins?
Using specific versions avoids unexpected changes in your pipeline behavior. 'Latest' can change anytime, causing builds to break or behave differently.
Click to reveal answer
intermediate
What happens if you don't specify a version for a shared library in Jenkins?
If no version is specified, Jenkins uses the default branch of the library, often 'master' or 'main'. This can lead to unpredictable pipeline results if the library changes.
Click to reveal answer
advanced
How can you manage multiple versions of a shared library in Jenkins?
You can tag or branch your shared library repository for each version. Then, in Jenkinsfile, use the tag or branch name in the @Library annotation to pick the version you want.
Click to reveal answer
How do you specify a version of a shared library in a Jenkinsfile?
AuseLibrary('lib-name', 'version')
Blibrary('lib-name', 'version')
C@Library('lib-name@version') _
Dimport library version
What is the risk of using the 'latest' version of a shared library in Jenkins?
ABuilds will always be faster
BBuilds may break due to unexpected changes
CIt locks the pipeline to an old version
DIt disables pipeline caching
If no version is specified for a shared library, Jenkins uses:
AThe last successful build version
BThe oldest tagged version
CAn error is thrown
DThe default branch of the library repository
How can you create different versions of a shared library?
ABy tagging or branching the library repository
BBy renaming the library folder
CBy changing Jenkins global settings
DBy using different Jenkins agents
What does the underscore (_) mean after the @Library annotation?
AIt loads the library into the pipeline script
BIt comments out the annotation
CIt specifies the library path
DIt defines a variable
Explain how to use library versioning in a Jenkins pipeline and why it is important.
Think about how you tell Jenkins which library code to use.
You got /4 concepts.
    Describe the consequences of not specifying a library version in Jenkins pipelines.
    Consider what happens when you don't lock the library code.
    You got /4 concepts.