use when.local=false to disable plugin steps locally

This commit is contained in:
Brad Rydzewski 2017-01-20 18:06:08 +07:00
parent def995b164
commit e4740667c0
4 changed files with 8 additions and 12 deletions

View file

@ -10,13 +10,13 @@ import (
type Constraints struct { type Constraints struct {
Repo Constraint Repo Constraint
Ref Constraint Ref Constraint
Runtime Constraint
Platform Constraint Platform Constraint
Environment Constraint Environment Constraint
Event Constraint Event Constraint
Branch Constraint Branch Constraint
Status Constraint Status Constraint
Matrix ConstraintMap Matrix ConstraintMap
Local types.BoolTrue
} }
// Match returns true if all constraints match the given input. If a single constraint // Match returns true if all constraints match the given input. If a single constraint

View file

@ -7,18 +7,14 @@ import "github.com/drone/drone/yaml"
// locally on your own computer. // locally on your own computer.
func PluginDisable(conf *yaml.Config, local bool) error { func PluginDisable(conf *yaml.Config, local bool) error {
for _, container := range conf.Pipeline { for _, container := range conf.Pipeline {
if len(container.Commands) != 0 || container.Detached { // skip build steps if local && !container.Constraints.Local.Bool() {
continue container.Disabled = true
} }
if isClone(container) { if isClone(container) {
container.Disabled = true container.Disabled = true
continue continue
} }
if local && container.Constraints.Runtime.Match("cli") {
container.Disabled = true
}
} }
return nil return nil
} }

View file

@ -15,14 +15,14 @@ func (b *BoolTrue) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err return err
} }
b.value, err = strconv.ParseBool(s) value, err := strconv.ParseBool(s)
if err != nil { if err == nil {
b.value = true b.value = !value
} }
return nil return nil
} }
// Bool returns the bool value. // Bool returns the bool value.
func (b BoolTrue) Bool() bool { func (b BoolTrue) Bool() bool {
return b.value return !b.value
} }

View file

@ -40,7 +40,7 @@ func TestBoolTrue(t *testing.T) {
if err != nil { if err != nil {
g.Fail(err) g.Fail(err)
} }
g.Assert(out.Bool()).Equal(false) g.Assert(out.Bool()).Equal(true)
}) })
g.It("should throw error when invalid", func() { g.It("should throw error when invalid", func() {