Restrict health metrics by branches in a multi branch pipeline job
Asked Answered
L

1

14

In a multibranch Jenkins job, you can decide to show health metrics and they are obtained from the branch with the worse health. This is fine, except that it is common to have feature branches that fail and thus bring a poor general status to the project. Is it possible to restrict the health metrics to consider only the master and development branches?

Lenin answered 24/1, 2018 at 7:52 Comment(1)
Sadly, probably not anytime soon: issues.jenkins-ci.org/browse/JENKINS-34502Hyades
B
3

You can try to change the healthMetrics node over a configure block:

configure { node ->
  node.remove(node.get('healthMetrics'))
  node / 'healthMetrics' << 'jenkins.branch.PrimaryBranchHealthMetric' {}
}

My approach was to change the health metric manually via the Web UI and compare the resulting XML of the job by appending config.xml to my job's URL like so: https://jenkins.example.com/job/my-folder/job/my-multibranch-pipeline-job/config.xml.

This Jenkins Job DSL Playground lets you easily try out the configure block.

Bowser answered 5/6, 2020 at 17:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.