@@ -479,21 +479,21 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
479479 targetPaths := parseTargetPaths (cc .workspaceConfig )
480480 buildGroup := Info ("Creating build..." )
481481 params := stainless.BuildNewParams {}
482- res , err := cc .client .Builds .New (
482+ build , err := cc .client .Builds .New (
483483 ctx ,
484484 params ,
485485 option .WithMiddleware (cc .AsMiddleware ()),
486486 )
487487 if err != nil {
488488 return err
489489 }
490-
491- buildGroup .Property ("build_id" , res .ID )
490+
491+ buildGroup .Property ("build_id" , build .ID )
492492
493493 if cmd .Bool ("wait" ) {
494494 waitGroup := Info ("Waiting for latest build to complete..." )
495495
496- res , err = waitForBuildCompletion (context .TODO (), cc .client , res , & waitGroup )
496+ build , err = waitForBuildCompletion (context .TODO (), cc .client , build , & waitGroup )
497497 if err != nil {
498498 return err
499499 }
@@ -503,18 +503,31 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
503503
504504 if shouldPull {
505505 pullGroup := Info ("Downloading build outputs..." )
506- if err := pullBuildOutputs (context .TODO (), cc .client , * res , targetPaths , & pullGroup ); err != nil {
506+ if err := pullBuildOutputs (context .TODO (), cc .client , * build , targetPaths , & pullGroup ); err != nil {
507507 pullGroup .Error ("Failed to download outputs: %v" , err )
508508 } else {
509509 pullGroup .Success ("Successfully downloaded all outputs" )
510510 }
511511 }
512512 }
513513
514- data := gjson .Parse (string (res .RawJSON ()))
514+ data := gjson .Parse (string (build .RawJSON ()))
515515 format := cmd .Root ().String ("format" )
516516 transform := cmd .Root ().String ("transform" )
517- return ShowJSON ("builds create" , data , format , transform )
517+ if err := ShowJSON ("builds create" , data , format , transform ); err != nil {
518+ return err
519+ }
520+
521+ for _ , target := range data .Get ("targets.@values" ).Array () {
522+ if target .Get ("status" ).String () == "not_started" ||
523+ target .Get ("commit.completed.conclusion" ).String () == "error" ||
524+ target .Get ("lint.completed.conclusion" ).String () == "error" ||
525+ target .Get ("test.completed.conclusion" ).String () == "error" {
526+ os .Exit (1 )
527+ }
528+ }
529+
530+ return nil
518531}
519532
520533func handleBuildsRetrieve (ctx context.Context , cmd * cli.Command ) error {
0 commit comments