Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(api/webhook): update hook status to skipped when build is skipped #993

Merged
merged 5 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
ecrupper marked this conversation as resolved.
Show resolved Hide resolved
}
}

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
Loading