mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 08:06:52 +02:00
use when.local=false to disable plugin steps locally
This commit is contained in:
parent
def995b164
commit
e4740667c0
@ -10,13 +10,13 @@ import (
|
||||
type Constraints struct {
|
||||
Repo Constraint
|
||||
Ref Constraint
|
||||
Runtime Constraint
|
||||
Platform Constraint
|
||||
Environment Constraint
|
||||
Event Constraint
|
||||
Branch Constraint
|
||||
Status Constraint
|
||||
Matrix ConstraintMap
|
||||
Local types.BoolTrue
|
||||
}
|
||||
|
||||
// Match returns true if all constraints match the given input. If a single constraint
|
||||
|
@ -7,18 +7,14 @@ import "github.com/drone/drone/yaml"
|
||||
// locally on your own computer.
|
||||
func PluginDisable(conf *yaml.Config, local bool) error {
|
||||
for _, container := range conf.Pipeline {
|
||||
if len(container.Commands) != 0 || container.Detached { // skip build steps
|
||||
continue
|
||||
if local && !container.Constraints.Local.Bool() {
|
||||
container.Disabled = true
|
||||
}
|
||||
|
||||
if isClone(container) {
|
||||
container.Disabled = true
|
||||
continue
|
||||
}
|
||||
|
||||
if local && container.Constraints.Runtime.Match("cli") {
|
||||
container.Disabled = true
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ func (b *BoolTrue) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
b.value, err = strconv.ParseBool(s)
|
||||
if err != nil {
|
||||
b.value = true
|
||||
value, err := strconv.ParseBool(s)
|
||||
if err == nil {
|
||||
b.value = !value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Bool returns the bool value.
|
||||
func (b BoolTrue) Bool() bool {
|
||||
return b.value
|
||||
return !b.value
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func TestBoolTrue(t *testing.T) {
|
||||
if err != nil {
|
||||
g.Fail(err)
|
||||
}
|
||||
g.Assert(out.Bool()).Equal(false)
|
||||
g.Assert(out.Bool()).Equal(true)
|
||||
})
|
||||
|
||||
g.It("should throw error when invalid", func() {
|
||||
|
Loading…
Reference in New Issue
Block a user