1
0
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:
Jack Morris 2019-04-17 10:24:39 +01:00 committed by GitHub
parent f043830bc4
commit a89e32141f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,9 @@ func (widget *Widget) apiKey() string {
func (widget *Widget) contentFrom(view *View) string {
var str string
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(
`["%d"][""][%s] [%s]%-6s[white]`,
idx,
@ -105,6 +108,7 @@ func (widget *Widget) contentFrom(view *View) string {
str = str + "\n"
}
}
return str
}