Merge pull request #1370 from glaszig/skip-ci-variants

skip build with any combination of "skip" and "ci"
This commit is contained in:
Brad Rydzewski 2015-12-12 20:56:06 -08:00
commit 7072c547be
2 changed files with 10 additions and 5 deletions

View file

@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"strings"
"regexp"
log "github.com/Sirupsen/logrus"
"github.com/drone/drone/engine"
@ -19,6 +20,8 @@ import (
"github.com/drone/drone/yaml/matrix"
)
var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
func PostHook(c *gin.Context) {
remote_ := remote.FromContext(c)
@ -38,10 +41,11 @@ func PostHook(c *gin.Context) {
return
}
// a build may be skipped if the text [CI SKIP]
// is found inside the commit message
if strings.Contains(build.Message, "[CI SKIP]") {
log.Infof("ignoring hook. [ci skip] found for %s")
// skip the build if any case-insensitive combination of the words "skip" and "ci"
// wrapped in square brackets appear in the commit message
skipMatch := skipRe.FindString(build.Message)
if len(skipMatch) > 0 {
log.Infof("ignoring hook. %s found in %s", skipMatch, build.Commit)
c.Writer.WriteHeader(204)
return
}

3
docs/build/build.md vendored
View file

@ -48,4 +48,5 @@ image: index.docker.io/library/golang:1.4
## Skipping builds
Skip a build by including the text `[CI SKIP]` in your commit message.
Skip a build by including any combination of `ci` and `skip` wrapped in square brackets
in your commit message. Examples: `[skip CI]` `[ci skip]`