chore: update default message in Drone CI/CD.
This commit is contained in:
parent
e3fc3f805d
commit
ba1db08ad2
14
plugin.go
14
plugin.go
@ -107,6 +107,12 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var icons = map[string]string{
|
||||||
|
"failure": "❗",
|
||||||
|
"cancelled": "❕",
|
||||||
|
"success": "✅",
|
||||||
|
}
|
||||||
|
|
||||||
func trimElement(keys []string) []string {
|
func trimElement(keys []string) []string {
|
||||||
var newKeys []string
|
var newKeys []string
|
||||||
|
|
||||||
@ -266,6 +272,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
case len(p.Config.Message) > 0:
|
case len(p.Config.Message) > 0:
|
||||||
message = p.Config.Message
|
message = p.Config.Message
|
||||||
default:
|
default:
|
||||||
|
p.Config.Format = formatMarkdown
|
||||||
message = p.Message()
|
message = p.Message()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,6 +442,8 @@ func (p Plugin) Send(bot *tgbotapi.BotAPI, msg tgbotapi.Chattable) error {
|
|||||||
|
|
||||||
// Message is plugin default message.
|
// Message is plugin default message.
|
||||||
func (p Plugin) Message() []string {
|
func (p Plugin) Message() []string {
|
||||||
|
icon := icons[strings.ToLower(p.Build.Status)]
|
||||||
|
|
||||||
if p.Config.GitHub {
|
if p.Config.GitHub {
|
||||||
return []string{fmt.Sprintf("%s/%s triggered by %s (%s)",
|
return []string{fmt.Sprintf("%s/%s triggered by %s (%s)",
|
||||||
p.Repo.FullName,
|
p.Repo.FullName,
|
||||||
@ -444,10 +453,11 @@ func (p Plugin) Message() []string {
|
|||||||
)}
|
)}
|
||||||
}
|
}
|
||||||
|
|
||||||
return []string{fmt.Sprintf("[%s] <%s> (%s)『%s』by %s",
|
return []string{fmt.Sprintf("%s*%s* [%s](%s)『%s』by %s",
|
||||||
|
icon,
|
||||||
p.Build.Status,
|
p.Build.Status,
|
||||||
|
p.Repo.FullName,
|
||||||
p.Build.Link,
|
p.Build.Link,
|
||||||
p.Commit.Branch,
|
|
||||||
p.Commit.Message,
|
p.Commit.Message,
|
||||||
p.Commit.Author,
|
p.Commit.Author,
|
||||||
)}
|
)}
|
||||||
|
@ -30,6 +30,7 @@ func TestMissingUserConfig(t *testing.T) {
|
|||||||
func TestDefaultMessageFormat(t *testing.T) {
|
func TestDefaultMessageFormat(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
|
FullName: "appleboy/go-hello",
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
Namespace: "appleboy",
|
Namespace: "appleboy",
|
||||||
},
|
},
|
||||||
@ -48,7 +49,7 @@ func TestDefaultMessageFormat(t *testing.T) {
|
|||||||
|
|
||||||
message := plugin.Message()
|
message := plugin.Message()
|
||||||
|
|
||||||
assert.Equal(t, []string{"[success] <https://github.com/appleboy/go-hello> (master)『update travis』by Bo-Yi Wu"}, message)
|
assert.Equal(t, []string{"✅*success* [appleboy/go-hello](https://github.com/appleboy/go-hello)『update travis』by Bo-Yi Wu"}, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultMessageFormatFromGitHub(t *testing.T) {
|
func TestDefaultMessageFormatFromGitHub(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user