Recall & Review
beginner
What is the purpose of loading libraries in a Jenkinsfile?
Loading libraries in a Jenkinsfile allows you to reuse shared code and functions across multiple pipelines, making your Jenkinsfiles cleaner and easier to maintain.
Click to reveal answer
beginner
How do you load a shared library in a Jenkinsfile?
You use the
@Library annotation followed by the library name, for example: @Library('my-shared-lib') _ at the top of your Jenkinsfile.Click to reveal answer
intermediate
What does the underscore (_) mean after the
@Library('lib-name') annotation?The underscore tells Jenkins to import the library and make its classes and functions available in the Jenkinsfile.Click to reveal answer
intermediate
Where do you configure shared libraries in Jenkins?
Shared libraries are configured in Jenkins under Manage Jenkins > Configure System > Global Pipeline Libraries. You define the library name, source code repository, and default version there.
Click to reveal answer
advanced
What is the difference between a global and a local library in Jenkins?
Global libraries are configured once in Jenkins and available to all pipelines. Local libraries are loaded from the same repository as the Jenkinsfile and are only available to that pipeline.
Click to reveal answer
How do you import a shared library named 'utils' in a Jenkinsfile?
✗ Incorrect
The correct syntax to import a shared library is using the @Library annotation followed by an underscore.
Where do you set up the repository URL for a shared library in Jenkins?
✗ Incorrect
Shared libraries are configured globally in Jenkins under Global Pipeline Libraries.
What does the underscore (_) do after the @Library annotation?
✗ Incorrect
The underscore tells Jenkins to import the library and make its contents available.
Which of the following is NOT true about shared libraries in Jenkins?
✗ Incorrect
While global shared libraries are configured in Jenkins, local shared libraries are loaded from the pipeline repository itself and are not configured globally.
What is a local library in Jenkins?
✗ Incorrect
Local libraries are stored in the same repository as the Jenkinsfile and only available to that pipeline.
Explain how to load and use a shared library in a Jenkinsfile.
Think about the syntax and where you configure the library.
You got /4 concepts.
Describe the difference between global and local libraries in Jenkins and when you might use each.
Consider scope and reuse.
You got /4 concepts.