fix(inputs.jenkins): Filter after searching sub-folders (#14105)
This commit is contained in:
parent
43ec383fc6
commit
3fbe624b98
|
|
@ -263,11 +263,6 @@ func (j *Jenkins) getJobDetail(jr jobRequest, acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out excluded or not included jobs
|
|
||||||
if !j.jobFilter.Match(jr.hierarchyName()) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
js, err := j.client.getJobs(context.Background(), &jr)
|
js, err := j.client.getJobs(context.Background(), &jr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -293,6 +288,11 @@ func (j *Jenkins) getJobDetail(jr jobRequest, acc telegraf.Accumulator) error {
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
// filter out excluded or not included jobs
|
||||||
|
if !j.jobFilter.Match(jr.hierarchyName()) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// collect build info
|
// collect build info
|
||||||
number := js.LastBuild.Number
|
number := js.LastBuild.Number
|
||||||
if number < 1 {
|
if number < 1 {
|
||||||
|
|
|
||||||
|
|
@ -797,6 +797,9 @@ func TestGatherJobs(t *testing.T) {
|
||||||
{Name: "ignore-1"},
|
{Name: "ignore-1"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"/job/ignore-1/api/json": &jobResponse{
|
||||||
|
Jobs: []innerJob{},
|
||||||
|
},
|
||||||
"/job/apps/api/json": &jobResponse{
|
"/job/apps/api/json": &jobResponse{
|
||||||
Jobs: []innerJob{
|
Jobs: []innerJob{
|
||||||
{Name: "k8s-cloud"},
|
{Name: "k8s-cloud"},
|
||||||
|
|
@ -810,6 +813,16 @@ func TestGatherJobs(t *testing.T) {
|
||||||
{Name: "2"},
|
{Name: "2"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"/job/apps/job/ignore-all/job/1/api/json": &jobResponse{
|
||||||
|
LastBuild: jobBuild{
|
||||||
|
Number: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/job/apps/job/ignore-all/job/2/api/json": &jobResponse{
|
||||||
|
LastBuild: jobBuild{
|
||||||
|
Number: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
"/job/apps/job/chronograf/api/json": &jobResponse{
|
"/job/apps/job/chronograf/api/json": &jobResponse{
|
||||||
LastBuild: jobBuild{
|
LastBuild: jobBuild{
|
||||||
Number: 1,
|
Number: 1,
|
||||||
|
|
@ -824,6 +837,16 @@ func TestGatherJobs(t *testing.T) {
|
||||||
{Name: "PR ignore"},
|
{Name: "PR ignore"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"/job/apps/job/k8s-cloud/job/PR%20ignore/api/json": &jobResponse{
|
||||||
|
LastBuild: jobBuild{
|
||||||
|
Number: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/job/apps/job/k8s-cloud/job/PR-ignore2/api/json": &jobResponse{
|
||||||
|
LastBuild: jobBuild{
|
||||||
|
Number: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
"/job/apps/job/k8s-cloud/job/PR-100/api/json": &jobResponse{
|
"/job/apps/job/k8s-cloud/job/PR-100/api/json": &jobResponse{
|
||||||
LastBuild: jobBuild{
|
LastBuild: jobBuild{
|
||||||
Number: 1,
|
Number: 1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue