-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathskip.go
39 lines (32 loc) · 1.12 KB
/
skip.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// SPDX-License-Identifier: Apache-2.0
package build
import (
"github.com/go-vela/types/pipeline"
)
// SkipEmptyBuild checks if the build should be skipped due to it
// not containing any steps besides init or clone.
//
//nolint:goconst // ignore init and clone constants
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 — 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 — 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 — 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 — it is likely no rulesets matched for the webhook payload"
}
}
return ""
}