But Jenkins reports: groovy.lang.MissingPropertyException: No such property: commonLib. What is the likely cause?
medium
A. The library name 'common-lib' is incorrect or not configured.
B. You must assign the library to a variable to use it like commonLib.
C. You forgot to add the underscore after @Library annotation.
D. Shared libraries cannot be used inside script blocks.
Solution
Step 1: Understand @Library usage with variable assignment
When using @Library('name') without assignment, library classes are imported globally, but to use a variable like commonLib, you must assign it.
Step 2: Identify the error cause
The error says commonLib is missing, meaning the library was not assigned to that variable.
Final Answer:
You must assign the library to a variable to use it like commonLib. -> Option B
Quick Check:
Assign library to variable to call methods [OK]
Hint: Assign library to variable to call methods [OK]
Common Mistakes:
Assuming library auto-creates variables
Thinking underscore fixes variable issues
Believing shared libraries can't be used in script blocks
5. You have multiple Jenkins pipelines that all use the same code to send notifications and run tests. How does using a shared library improve your setup?
medium
A. It duplicates the code in each pipeline for faster execution.
B. It lets each pipeline run notifications and tests in parallel automatically.
C. It removes the need to write any pipeline scripts at all.
D. It centralizes notification and test code, so updates apply everywhere automatically.
Solution
Step 1: Identify the problem with duplicated code
Having the same notification and test code copied in many pipelines causes maintenance issues.
Step 2: Explain how shared libraries solve this
Shared libraries keep this code in one place, so changing it once updates all pipelines using it.
Final Answer:
It centralizes notification and test code, so updates apply everywhere automatically. -> Option D
Quick Check:
Central code means easier updates and less duplication [OK]
Hint: Centralize common code to update once for all pipelines [OK]
Common Mistakes:
Thinking shared libraries run steps in parallel
Believing shared libraries remove all scripting
Assuming shared libraries duplicate code instead of reusing
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.