1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

WTF-400 Move jobNameRegex setting into Jenkins settings

This commit is contained in:
Chris Cummer 2019-04-17 17:42:51 -07:00
commit 2ed3c087b8
3 changed files with 19 additions and 8 deletions

View File

@ -2,6 +2,10 @@
## Unreleased ## Unreleased
### ⚡️ Added
* Jenkins now supports coloured balls, [#358](https://github.com/wtfutil/wtf/issues/358) by [@rudolphjacksonm](https://github.com/rudolphjacksonm)
## 0.6.0 ## 0.6.0
### ⚡️ Added ### ⚡️ Added

View File

@ -13,6 +13,7 @@ type Settings struct {
common *cfg.Common common *cfg.Common
apiKey string apiKey string
jobNameRegex string
successBallColor string successBallColor string
url string url string
user string user string
@ -26,6 +27,7 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config) *Settings {
common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig), common: cfg.NewCommonSettingsFromYAML(name, configKey, ymlConfig),
apiKey: localConfig.UString("apiKey", os.Getenv("WTF_JENKINS_API_KEY")), apiKey: localConfig.UString("apiKey", os.Getenv("WTF_JENKINS_API_KEY")),
jobNameRegex: localConfig.UString("jobNameRegex", ".*"),
successBallColor: localConfig.UString("successBallColor", "blue"), successBallColor: localConfig.UString("successBallColor", "blue"),
url: localConfig.UString("url"), url: localConfig.UString("url"),
user: localConfig.UString("user"), user: localConfig.UString("user"),

View File

@ -7,6 +7,7 @@ import (
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
"github.com/rivo/tview" "github.com/rivo/tview"
"github.com/wtfutil/wtf/wtf" "github.com/wtfutil/wtf/wtf"
"regexp"
) )
const HelpText = ` const HelpText = `
@ -91,15 +92,19 @@ func (widget *Widget) display() {
func (widget *Widget) contentFrom(view *View) string { func (widget *Widget) contentFrom(view *View) string {
var str string var str string
for idx, job := range view.Jobs { for idx, job := range view.Jobs {
str = str + fmt.Sprintf( var validID = regexp.MustCompile(widget.settings.jobNameRegex)
`["%d"][""][%s] [%s]%-6s[white]`,
idx,
widget.rowColor(idx),
widget.jobColor(&job),
job.Name,
)
str = str + "\n" if validID.MatchString(job.Name) {
str = str + fmt.Sprintf(
`["%d"][""][%s] [%s]%-6s[white]`,
idx,
widget.rowColor(idx),
widget.jobColor(&job),
job.Name,
)
str = str + "\n"
}
} }
return str return str