Skip to content

Commit

Permalink
enhance(api/webhook): update hook status to skipped when build is ski…
Browse files Browse the repository at this point in the history
…pped
  • Loading branch information
ecrupper committed Oct 26, 2023
1 parent 7370602 commit cc5c895
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/build/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}

Expand Down
4 changes: 4 additions & 0 deletions api/webhook/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cc5c895

Please sign in to comment.