skip build with any combination of "skip" and "ci"
a commit message containing any case-insensitive variant of the above two words wrapped in square brackets will skip the build. examples: [ci skip], [skip CI] this reintroduces pr #1134 and additionally logs the matched skip instruction.
This commit is contained in:
parent
d9296c0453
commit
77b5c6246d
1 changed files with 7 additions and 4 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/drone/drone/engine"
|
"github.com/drone/drone/engine"
|
||||||
|
@ -38,10 +39,12 @@ func PostHook(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// a build may be skipped if the text [CI SKIP]
|
// skip the build if any case-insensitive combination of the words "skip" and "ci"
|
||||||
// is found inside the commit message
|
// wrapped in square brackets appear in the commit message
|
||||||
if strings.Contains(build.Message, "[CI SKIP]") {
|
skipRe := regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
|
||||||
log.Infof("ignoring hook. [ci skip] found for %s")
|
skipMatches := skipRe.FindStringSubmatch(build.Message)
|
||||||
|
if len(skipMatches) > 0 {
|
||||||
|
log.Infof("ignoring hook. %s found in %s", skipMatches[0], build.Commit)
|
||||||
c.Writer.WriteHeader(204)
|
c.Writer.WriteHeader(204)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue