static-web-apps-cli icon indicating copy to clipboard operation
static-web-apps-cli copied to clipboard

Getting zero exit code on deploy failure

Open pstovik opened this issue 1 year ago • 3 comments

Describe the bug There is an upload failure, but CLI returns 0 exit code.

To Reproduce Steps to reproduce the behavior:

  1. Given issue with SWA Azure - like this one => https://github.com/Azure/static-web-apps/issues/1097
  2. When running the command 'swa deploy --env production'
  3. Then I can see error in log

✖ Deployment Failed :( ✖ Deployment Failure Reason: Failed to deploy the Azure Functions. and exit code is "0"

Expected behavior Have non-zero exit code, to get failures in pipelines

Screenshots 2023-03-08 non-zero

Desktop (please complete the following information):

  • OS: Debian GNU/Linux 11 (bullseye)
  • Version 1.0.6

pstovik avatar Mar 08 '23 13:03 pstovik

We are getting the same behaviour when trying to deploy a new env without any free slots available. Our workaround for pipelines is a shell script that greps the output for a keyword:

swa deploy -O build/your-app --env "full_env"  2>&1 | tee run.log
if grep -q BadRequest run.log; then exit 1; else exit 0; fi

flexwie avatar Jun 01 '23 06:06 flexwie

the always 0 exit code makes it really hard to use this in any CI/CD scenario. I want to fail my GitHub Actions workflow if deploy fails, but since the swa exit code is is 0, GitHub Actions assumes it succeeded (as will most/all CI systems).

dylan-smith avatar Sep 19 '23 20:09 dylan-smith

yea it is anoying. We run into this from first try because 1st we thought "nice that was easy" but then "oh no, it errors but it does not fail".

It needs to return an error code, else we need to look into the job everytime.

hbroer avatar Oct 11 '23 13:10 hbroer