But Jenkins throws an error saying Missing required underscore after @Library annotation. How do you fix it?
medium
A. Change @Library to @LoadLibrary
B. Remove the parentheses from @Library
C. Place the underscore before the annotation like _ @Library('commonLib')
D. Add an underscore _ immediately after the annotation like @Library('commonLib') _
Solution
Step 1: Identify the syntax error from the message
The error says the underscore is missing after @Library, which is required syntax.
Step 2: Correct the syntax by adding underscore
Add an underscore immediately after the annotation: @Library('commonLib') _.
Final Answer:
Add an underscore _ immediately after the annotation like @Library('commonLib') _ -> Option D
Quick Check:
Underscore after @Library fixes syntax [OK]
Hint: Always put underscore right after @Library(...) [OK]
Common Mistakes:
Omitting the underscore
Placing underscore before annotation
Changing annotation name incorrectly
5. You want to load two shared libraries named 'utils' and 'helpers' in your Jenkinsfile. Which is the correct way to do this using the @Library annotation?
hard
A. @Library('utils_helpers') _
B. @Library('utils') _ @Library('helpers') _
C. @Library(['utils', 'helpers']) _
D. @Library('utils,helpers') _
Solution
Step 1: Recall how to load multiple libraries
Multiple libraries can be loaded by passing a list of names inside @Library annotation.
Step 2: Identify correct syntax for multiple libraries
The correct syntax is @Library(['utils', 'helpers']) _ which loads both libraries at once.
Final Answer:
@Library(['utils', 'helpers']) _ -> Option C
Quick Check:
Use list inside @Library for multiple libs [OK]
Hint: Use list syntax inside @Library to load many libs [OK]
Common Mistakes:
Trying to use multiple @Library annotations
Passing comma-separated string instead of list
Combining names into one string without list
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.