Pre/post script with non-zero exit does not fail build
surpher opened this issue · 2 comments
Setup
Running pact tests from an iOS build.
Using pre-actions and post-actions of the scheme in the Xcode project to start/stop the pact mock service and then upload to the Pact broker.
pre-actions
"${PACT_BIN}/pact-mock-service" start --pact-specification-version 2.0.0 --log "${SRCROOT}/tmp/pact.log" --pact-dir "${SRCROOT}/tmp/pacts" -p 1234
post-actions
"${PACT_BIN}/pact-mock-service" stop
"${PACT_BIN}/pact-broker" publish "${SRCROOT}/tmp/pacts" --consumer-app-version=1.0.1 --tag master
Expected result:
Non-zero exit of these scripts should fail the CI.
Actual result:
Non-zero exit codes from pre/post test scripts don't result in the actual build being marked as an error or failure by Xcode, so it won't actually fail CI.
Thanks for that. Just for context for the scripts above, I obviously set up the PACT_BIN and then the pact broker credentials environment variables separately for these scripts to work as well, that's just the minimum context to explain the issue.
eg. even if you just put exit 1
in those scripts, it doesn't fail
After some investigation Xcode's scheme scripts indeed do not honour non-zero exit codes.
I would suggest running pact-broker
in a seperate CI step rather than in a Schemes' Test post-actions script.