The manifest contains one failed check and one successful check. The CI command prints false, then true, and exits with status 0. Reverse the two entries and the exact same command fails. A release gate should give the same answer either way.

The same two check results give different shell statuses when reordered

Reproduce the green build

Run both commands in a shell without errexit so you can inspect their statuses. These results were recorded with jq 1.7.

echo '[{"ok":false},{"ok":true}]' | jq -e '.[] | .ok' echo "status=$?" echo '[{"ok":true},{"ok":false}]' | jq -e '.[] | .ok' echo "status=$?" 

Terminal output: false then true exits with status 0

.[] | .ok emits one JSON value per check. On a successful run, jq's -e option uses the last output value to set the exit status. An earlier false stays in the log, but it doesn't make the command fail.

Terminal output: true then false exits with status 1

Give the shell one verdict

If the gate requires at least one check and every check must explicitly report true, write both conditions into the filter.

jq -e 'length > 0 and all(.[]; .ok == true)' checks.json 

The filter combines a nonempty manifest with all checks explicitly true

checks.json must contain a single JSON array of objects. The comparison .ok == true rejects a missing value and the string "true". For this gate, those values mean that the producer didn't supply a passing result in the expected format.

Only a JSON boolean true passes; missing and quoted true fail

Keep the length check: all returns true for an empty array. Without a length check, a build could pass before running a single check.

An empty array passes all alone but fails the nonempty gate

Prove the gate before using it in CI

Try both orderings, a passing file, and an empty manifest. A missing value is worth testing too. This loop sends one JSON document per run; it doesn't pipe a stream of documents into a single jq invocation.

for manifest in \ '[{"ok":false},{"ok":true}]' '[{"ok":true},{"ok":false}]' \ '[{"ok":true},{"ok":true}]' '[]' '[{}]' '[{"ok":"true"}]' do echo "$manifest" | jq -e 'length > 0 and all(.[]; .ok == true)' echo "status=$?" done 

The fixed filter rejects both orders of the mixed results

The expected statuses are 1, 1, 0, 1, 1, 1. In a deployment script, use jq's status to decide whether to proceed; keep the per-check output in a separate diagnostic step.

All six test cases and their observed shell statuses

If the input is newline-delimited JSON or can contain multiple top-level values, reduce the whole stream to one verdict first. For a file expected to contain exactly one manifest, jq -s lets you check the outer array has exactly one element before validating the manifest itself.

One verdict belongs to the entire input, not just its final JSON document

Reference