Skip to content

O365 CLI doesn't return non-zero exit code on failed commands #1092

@andrewconnell

Description

@andrewconnell

TL;DR

When login fails, the CLI exit with an error code (1). Apparently it doesn't do that in v2... in fact, it seems like other commands (uploading app package & deploying), when they fail, aren't existing with a non-zero return code.

Expected Behavior

When a CLI command fails, the CLI returns a non-zero exit code.

Observed Behavior

When a CLI command fails, the CLI returns a zero exit code, indicating the process completed successfully, even when the command fails.

I only checked three commands:

  • o365 login
  • o365 spo app add
  • o365 spo app deploy

Background

Noticed this in my CI/CD automation. I use the CLI for uploading & deploying SharePoint packages to SPO. Everything was working fine until today when my deploy steps were hanging and eventually timing out.

Inspection of the logs traced back to a failed login as I was using the v1 vs newer v2 CLI syntax (*I was using the o365 spo login .. instead of o365 login ..), but the step wasn't failing. Steps fail in CD when they detect a non-zero exit code from the command.

The following image shows a failed login from the logs, BUT notice the green arrow where the task is not recognized as failing. I noticed the same thing where the upload step (o365 spo add app ...) was also failing in the logs, but the step wasn't seen as a failed step.

image

Another example from uploading & deploying an app package... notice the first one is even failing (node.js error) but green status text indicates the process was successful, same with the check in the top right.

image

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions