Job 'deploy' lists 'needs: [build, test]'. Which expression correctly runs 'deploy' only when both 'build' and 'test' concluded successfully?
Select an answer to reveal the explanation.
Short Explanation and Infographic
When you need an explicit check of each dependency's outcome, read needs.<job_id>.result. success() alone is often enough with needs, but the needs.*.result form is explicit and exam-friendly.
Full explanation below image
Full Explanation
The needs context exposes the results and outputs of upstream jobs. needs.build.result and needs.test.result each evaluate to strings such as success, failure, cancelled, or skipped. Combining them with && makes the deploy job's condition explicit. success() returns true when none of the previous steps or jobs that this job depends on have failed or been cancelled — so with needs it often works, but the question asks for the expression that explicitly checks both results. always() runs even on failure, so it is wrong here. There is no jobs.build.success property in the expression language; use needs or the status functions. Remember that skipped upstream jobs report result skipped, which is not equal to success.