From c07d4167ea895b951d5cfa9a59c62c5e4ed9fd6a Mon Sep 17 00:00:00 2001 From: ecrupper Date: Wed, 11 Sep 2024 09:12:58 -0500 Subject: [PATCH] enhance: add a status call for failed compilation --- api/webhook/post.go | 7 +++++++ scm/github/repo.go | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/api/webhook/post.go b/api/webhook/post.go index 7ca9e3900..3a95aa5bc 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -405,8 +405,15 @@ func PostWebhook(c *gin.Context) { h.SetStatus(constants.StatusFailure) h.SetError(err.Error()) + b.SetStatus(constants.StatusError) + util.HandleError(c, code, err) + err = scm.FromContext(c).Status(ctx, repo.GetOwner(), b, repo.GetOrg(), repo.GetName()) + if err != nil { + l.Debugf("unable to set commit status for %s/%d: %v", repo.GetFullName(), b.GetNumber(), err) + } + return } diff --git a/scm/github/repo.go b/scm/github/repo.go index ad9db4271..395c5e375 100644 --- a/scm/github/repo.go +++ b/scm/github/repo.go @@ -335,7 +335,14 @@ func (c *client) Status(ctx context.Context, u *api.User, b *api.Build, org, nam description = "build was skipped as no steps/stages found" default: state = "error" - description = "there was an error" + + // if there is no build, then this status update is from a failed compilation + if b.GetID() == 0 { + description = "error compiling pipeline - check audit for more information" + url = fmt.Sprintf("%s/%s/%s/hooks", c.config.WebUIAddress, org, name) + } else { + description = "there was an error" + } } // check if the build event is deployment