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" "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"
@ -19,6 +20,8 @@ import (
"github.com/drone/drone/yaml/matrix" "github.com/drone/drone/yaml/matrix"
) )
var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`)
func PostHook(c *gin.Context) { func PostHook(c *gin.Context) {
remote_ := remote.FromContext(c) remote_ := remote.FromContext(c)
@ -38,10 +41,11 @@ 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]") { skipMatch := skipRe.FindString(build.Message)
log.Infof("ignoring hook. [ci skip] found for %s") if len(skipMatch) > 0 {
log.Infof("ignoring hook. %s found in %s", skipMatch, build.Commit)
c.Writer.WriteHeader(204) c.Writer.WriteHeader(204)
return return
} }

3
docs/build/build.md vendored
View file

@ -48,4 +48,5 @@ image: index.docker.io/library/golang:1.4
## Skipping builds ## 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]`