From cc5c89568c266c44665f9c5b6d514266ce1fd469 Mon Sep 17 00:00:00 2001 From: ecrupper Date: Thu, 26 Oct 2023 13:10:37 -0500 Subject: [PATCH] enhance(api/webhook): update hook status to skipped when build is skipped --- api/build/skip.go | 8 ++++---- api/webhook/post.go | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/build/skip.go b/api/build/skip.go index 2d934fb93..8a6eeeeb7 100644 --- a/api/build/skip.go +++ b/api/build/skip.go @@ -13,25 +13,25 @@ import ( func SkipEmptyBuild(p *pipeline.Build) string { if len(p.Stages) == 1 { if p.Stages[0].Name == "init" { - return "skipping build since only init stage found" + return "skipping build since only init stage found. It is likely no rulesets matched for the webhook payload." } } if len(p.Stages) == 2 { if p.Stages[0].Name == "init" && p.Stages[1].Name == "clone" { - return "skipping build since only init and clone stages found" + return "skipping build since only init and clone stages found. It is likely no rulesets matched for the webhook payload." } } if len(p.Steps) == 1 { if p.Steps[0].Name == "init" { - return "skipping build since only init step found" + return "skipping build since only init step found. It is likely no rulesets matched for the webhook payload." } } if len(p.Steps) == 2 { if p.Steps[0].Name == "init" && p.Steps[1].Name == "clone" { - return "skipping build since only init and clone steps found" + return "skipping build since only init and clone steps found. It is likely no rulesets matched for the webhook payload." } } diff --git a/api/webhook/post.go b/api/webhook/post.go index aa4449194..47562f80f 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -532,6 +532,10 @@ func PostWebhook(c *gin.Context) { // set build to successful status b.SetStatus(constants.StatusSkipped) + // set hook status and message + h.SetStatus(constants.StatusSkipped) + h.SetError(skip) + // send API call to set the status on the commit err = scm.FromContext(c).Status(ctx, u, b, repo.GetOrg(), repo.GetName()) if err != nil {