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,15 +95,19 @@ func (widget *Widget) apiKey() string {
|
||||
func (widget *Widget) contentFrom(view *View) string {
|
||||
var str string
|
||||
for idx, job := range view.Jobs {
|
||||
str = str + fmt.Sprintf(
|
||||
`["%d"][""][%s] [%s]%-6s[white]`,
|
||||
idx,
|
||||
widget.rowColor(idx),
|
||||
widget.jobColor(&job),
|
||||
job.Name,
|
||||
)
|
||||
regex := wtf.Config.UString("wtf.mods.jenkins.jobNameRegex", ".*")
|
||||
var validID = regexp.MustCompile(regex)
|
||||
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"
|
||||
str = str + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
return str
|
||||
|
Loading…
x
Reference in New Issue
Block a user