D. Pipeline syntax requires 'steps' outside 'script'
Solution
Step 1: Check variable definitions
The buildStatus variable is not defined in the pipeline context.
Step 2: Verify standard Jenkins variables
In Jenkins, use currentBuild.result or define buildStatus from previous steps to check status.
Final Answer:
buildStatus variable is undefined -> Option A
Quick Check:
Undefined variables cause runtime errors [OK]
Hint: Check for undefined variables in scripts [OK]
Common Mistakes:
Assuming error() usage is wrong
Ignoring undefined variables without context
Misplacing steps and script blocks
5. You want your Jenkins pipeline to fail fast if any test stage fails, but continue running other stages if tests pass. Which approach best implements this?
hard
A. Use sleep() to delay failure until all tests complete
B. Use try-catch around test stages and call error() in catch
C. Use error() inside each test stage to stop pipeline on failure
D. Use catchError to mark test failures but continue pipeline
Solution
Step 1: Understand fail fast requirement
Fail fast means stop pipeline immediately on test failure, so no further stages run.
Step 2: Evaluate options
Using error() inside each test stage stops pipeline immediately on failure, matching fail fast.
Final Answer:
Use error() inside each test stage to stop pipeline on failure -> Option C
Quick Check:
Fail fast = error() stops pipeline immediately [OK]
Hint: Use error() in failing stages to stop pipeline fast [OK]
Common Mistakes:
Using catchError which allows pipeline to continue
Using try-catch which delays failure
Using sleep() which only delays, not fails
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.