mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-12 18:45:28 +00:00
slack: implement on_change
This commit is contained in:
parent
b27572dc43
commit
52c8622f59
1 changed files with 9 additions and 4 deletions
|
@ -24,17 +24,22 @@ type Slack struct {
|
||||||
Started bool `yaml:"on_started,omitempty"`
|
Started bool `yaml:"on_started,omitempty"`
|
||||||
Success bool `yaml:"on_success,omitempty"`
|
Success bool `yaml:"on_success,omitempty"`
|
||||||
Failure bool `yaml:"on_failure,omitempty"`
|
Failure bool `yaml:"on_failure,omitempty"`
|
||||||
|
Change bool `yaml:"on_change,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Slack) Send(context *model.Request) error {
|
func (s *Slack) Send(context *model.Request) error {
|
||||||
switch {
|
switch {
|
||||||
case context.Commit.Status == "Started" && s.Started:
|
case context.Commit.Status == "Started" && s.Started:
|
||||||
return s.sendStarted(context)
|
return s.sendStarted(context)
|
||||||
case context.Commit.Status == "Success" && s.Success:
|
case context.Commit.Status == "Success":
|
||||||
|
if s.Success || (s.Change && context.Prior.Status != context.Commit.Status) {
|
||||||
return s.sendSuccess(context)
|
return s.sendSuccess(context)
|
||||||
case context.Commit.Status == "Failure" && s.Failure:
|
}
|
||||||
|
case context.Commit.Status == "Failure":
|
||||||
|
if s.Failure || (s.Change && context.Prior.Status != context.Commit.Status) {
|
||||||
return s.sendFailure(context)
|
return s.sendFailure(context)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue