But Jenkins throws a syntax error. What is the likely cause?
medium
A. Missing braces around the 'always' block
B. Incorrect indentation inside 'stages'
C. Using 'always' inside 'post' without a condition
D. Missing 'steps' block inside 'always'
Solution
Step 1: Review 'post' section syntax
Each condition like 'always' must be followed by braces { ... } containing steps or actions.
Step 2: Check the given snippet
'always echo ...' lacks braces after 'always', causing a syntax error.
Final Answer:
Missing braces around the 'always' block -> Option A
Quick Check:
Post conditions need braces { block } [OK]
Hint: Post conditions like 'always' require { block } [OK]
Common Mistakes:
Forgetting braces around post condition blocks
Assuming indentation causes syntax error
Thinking 'always' needs no condition
5. You want a Jenkins job to run these steps: build, test, and deploy. You also want to send a notification only if the deploy step fails. Which job configuration sections should you use to organize this?
hard
A. Use 'post' for build, test, deploy; use 'stages' with 'failure' for notification
B. Use 'environment' for build, test, deploy; use 'post' with 'always' for notification
C. Use 'stages' for build, test, deploy; use 'post' with 'failure' for notification
D. Use 'triggers' for build, test, deploy; use 'post' with 'success' for notification
Solution
Step 1: Organize main tasks
Use 'stages' section to split the job into build, test, and deploy steps.
Step 2: Handle failure notifications
Use 'post' section with 'failure' condition to send notification if deploy fails.
Final Answer:
Use 'stages' for build, test, deploy; use 'post' with 'failure' for notification -> Option C
Quick Check:
Stages for tasks, post failure for alerts [OK]
Hint: Stages for steps, post failure for alerts [OK]
Common Mistakes:
Putting main tasks inside post section
Using post success instead of failure for alerts
Confusing triggers with task steps
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.