A. The @Library annotation cannot be used inside the script block.
B. The library name 'toolsLib' is invalid syntax.
C. The function toolFunc() must be called with library() step.
D. The echo statement is missing parentheses.
Solution
Step 1: Check usage of @Library annotation
The @Library annotation must be placed at the top of the Jenkinsfile, not inside script blocks or stages.
Step 2: Identify error cause
Using @Library inside the script block causes a syntax error; explicit loading with library() should be used inside scripts.
Final Answer:
The @Library annotation cannot be used inside the script block. -> Option A
Quick Check:
@Library only at top, not inside script [OK]
Hint: Put @Library only at the top of Jenkinsfile [OK]
Common Mistakes:
Placing @Library inside pipeline steps
Confusing explicit and implicit loading syntax
Assuming library() is optional inside script
Ignoring syntax error from misplaced annotation
5. You want to load two shared libraries in a Jenkins pipeline: 'libA' implicitly and 'libB' explicitly. Which Jenkinsfile snippet correctly achieves this?