Support multiple attachments (#29)
* Support multiple attachments * Support single attachment syntax in addition to multiple * Re-add import Goland removed while optimizing imports for me.
This commit is contained in:
parent
20edd9c7e3
commit
17393400a4
6
main.go
6
main.go
|
@ -79,6 +79,11 @@ func main() {
|
|||
Usage: "attachment filename",
|
||||
EnvVar: "PLUGIN_ATTACHMENT",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "attachments",
|
||||
Usage: "attachment filename(s)",
|
||||
EnvVar: "PLUGIN_ATTACHMENTS",
|
||||
},
|
||||
|
||||
// Drone environment
|
||||
// Repo
|
||||
|
@ -375,6 +380,7 @@ func run(c *cli.Context) error {
|
|||
Subject: c.String("template.subject"),
|
||||
Body: c.String("template.body"),
|
||||
Attachment: c.String("attachment"),
|
||||
Attachments: c.StringSlice("attachments"),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ type (
|
|||
Subject string
|
||||
Body string
|
||||
Attachment string
|
||||
Attachments []string
|
||||
}
|
||||
|
||||
Plugin struct {
|
||||
|
@ -203,6 +204,10 @@ func (p Plugin) Exec() error {
|
|||
message.Attach(p.Config.Attachment)
|
||||
}
|
||||
|
||||
for _, attachment := range p.Config.Attachments {
|
||||
message.Attach(attachment)
|
||||
}
|
||||
|
||||
if err := gomail.Send(closer, message); err != nil {
|
||||
log.Errorf("Could not send email to %q: %v", recipient, err)
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue