Skip to content

Commit

Permalink
chore: skip post_build on build failure (aws#18365)
Browse files Browse the repository at this point in the history
According to the docs on CodeBuild [build transitions], the `POST_BUILD` step is
always run after `BUILD`, even if `BUILD` fails. This can mean in our pipeline
we can fail the build, and then wait for the (currently very expensive) packing
step to run completely before the job fails. This change short-circuits the
logic so we only run pack if the build succeeded.

[build transitions]: https://docs.aws.amazon.com/codebuild/latest/userguide/view-build-details.html


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
njlynch authored and TikiTDO committed Feb 21, 2022
1 parent 6997d0f commit 877917f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ phases:
- /bin/bash ./scripts/transform.sh
post_build:
commands:
# Short-circuit: Don't run pack if the above build failed.
- '[[ "$CODEBUILD_BUILD_SUCCEEDING" -eq 1 ]] || exit 1'
- "[ -f .BUILD_COMPLETED ] && /bin/bash ./pack.sh"
- /bin/bash ./scripts/cache-store.sh
artifacts:
Expand Down

0 comments on commit 877917f

Please sign in to comment.