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?
Restrict health metrics by branches in a multi branch pipeline job
Asked Answered
Sadly, probably not anytime soon: issues.jenkins-ci.org/browse/JENKINS-34502 –
Hyades
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.
© 2022 - 2024 — McMap. All rights reserved.