mirror of
https://github.com/appleboy/drone-telegram.git
synced 2026-06-04 18:23:45 +08:00
Add support for generic templates by using custom extra vars (#84)
* Fix DOCS.md example configuration with custom message from file * Move .test.message to a better named file * Add support for additional, custom extra vars to be used in the message template * Add cmdline/envvars to support the extra vars * Enhance DOCS.md with example configuration using generic template file with custom vars * Add testcase for custom template vars
This commit is contained in:
committed by
Bo-Yi Wu
parent
866e25b433
commit
b7f97df101
+32
-1
@@ -347,7 +347,38 @@ func TestMessageFile(t *testing.T) {
|
||||
Config: Config{
|
||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||
MessageFile: "tests/.test.message",
|
||||
MessageFile: "tests/message.txt",
|
||||
},
|
||||
}
|
||||
|
||||
err := plugin.Exec()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestTemplateVars(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Name: "go-hello",
|
||||
Namespace: "appleboy",
|
||||
},
|
||||
Commit: Commit{
|
||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
Author: "Bo-Yi Wu",
|
||||
Branch: "master",
|
||||
Message: "This is a test commit msg",
|
||||
},
|
||||
Build: Build{
|
||||
Number: 101,
|
||||
Status: "success",
|
||||
Link: "https://github.com/appleboy/go-hello",
|
||||
},
|
||||
|
||||
Config: Config{
|
||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||
Format: "markdown",
|
||||
MessageFile: "tests/message_template.txt",
|
||||
TemplateVars: `{"env":"testing","version":"1.2.0-SNAPSHOT"}`,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user