5. How can you modify a Jenkins pipeline to run Selenium Java tests only if the build stage succeeds, and always archive test reports regardless of test results?
hard
A. Use 'when' condition to skip archiving if tests fail
B. Run tests in parallel with build stage and archive in 'failure' block
C. Skip build stage and run tests directly, archive in 'success' block
D. Use 'post' block with 'always' to archive reports and normal stages for build and test
Solution
Step 1: Ensure test stage runs after successful build
By default, stages run sequentially; test stage runs only if build succeeds.
Step 2: Use 'post' block with 'always' to archive reports
The 'post' block with 'always' runs regardless of test success or failure, ensuring reports are archived.
Final Answer:
Use 'post' block with 'always' to archive reports and normal stages for build and test -> Option D
Quick Check:
Sequential stages + post always archive = D [OK]
Hint: Use post { always { ... } } to archive reports every run [OK]
Common Mistakes:
Running tests in parallel with build
Archiving only on success or failure
Skipping build stage before tests
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.