Skip to content

Commit

Permalink
fix for when pipelines and steps are excluded (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Sheldon authored Nov 5, 2019
1 parent 96fb73a commit 593ac31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions plugin/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ func parsePipelines(data string, build drone.Build, repo drone.Repo, token strin
"name": repo.Name,
}).Infoln("excluding pipeline", resource.Attrs["name"])

resource.Trigger.Event.Exclude = []string{"*"}
// if only Trigger.Paths is set, Trigger.Attrs will be unset, so it must be initialized
if resource.Trigger.Attrs == nil {
resource.Trigger.Attrs = make(map[string]interface{})
}
resource.Trigger.Attrs["event"] = map[string][]string{"exclude": []string{"*"}}
}
}

Expand Down Expand Up @@ -135,7 +139,11 @@ func parsePipelines(data string, build drone.Build, repo drone.Repo, token strin
"name": repo.Name,
}).Infoln("excluding step", step.Attrs["name"])

step.When.Event.Exclude = []string{"*"}
// if only When.Paths is set, When.Attrs will be unset, so it must be initialized
if step.When.Attrs == nil {
step.When.Attrs = make(map[string]interface{})
}
step.When.Attrs["event"] = map[string][]string{"exclude": []string{"*"}}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type (
}

conditions struct {
Event condition `yaml:"event,omitempty"`
Paths condition `yaml:"paths,omitempty"`
Attrs map[string]interface{} `yaml:",inline"`
}
Expand Down Expand Up @@ -96,6 +95,13 @@ func (p *plugin) Convert(ctx context.Context, req *converter.Request) (*drone.Co
data := req.Config.Data
resources, pathsSeen, err := parsePipelines(data, req.Build, req.Repo, p.token)
if err != nil {
logrus.WithFields(logrus.Fields{
"action": req.Build.Action,
"after": req.Build.After,
"before": req.Build.Before,
"namespace": req.Repo.Namespace,
"name": req.Repo.Name,
}).Errorln(err)
return nil, nil
}

Expand Down

0 comments on commit 593ac31

Please sign in to comment.