mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Allow users to filter jenkins jobs by regex
Allows users to filter the Jenkins jobs shown in the widget by providing a regular expression in the config file. The regex should be specified in the config like so: ``` jobNameRegex: ^[a-z]+.$ ``` Another example: ``` jobNameRegex^[a-z]+\[[0-9]+\]$ ```
This commit is contained in:
parent
f043830bc4
commit
a89e32141f
@ -95,6 +95,9 @@ func (widget *Widget) apiKey() string {
|
|||||||
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 {
|
||||||
|
regex := wtf.Config.UString("wtf.mods.jenkins.jobNameRegex", ".*")
|
||||||
|
var validID = regexp.MustCompile(regex)
|
||||||
|
if validID.MatchString(job.Name) {
|
||||||
str = str + fmt.Sprintf(
|
str = str + fmt.Sprintf(
|
||||||
`["%d"][""][%s] [%s]%-6s[white]`,
|
`["%d"][""][%s] [%s]%-6s[white]`,
|
||||||
idx,
|
idx,
|
||||||
@ -105,6 +108,7 @@ func (widget *Widget) contentFrom(view *View) string {
|
|||||||
|
|
||||||
str = str + "\n"
|
str = str + "\n"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user