jenkinsci / jenkinsci/cloudbees-folder-plugin
set `healthMetrics` via job DSL
- Dominant language
- Java
- Stars
- 59
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
### What feature do you want to see added?
I would like to set a folder's `healthMetrics` (specifically for multibranch pipelines) via job-dsl. I've been experimenting with doing this via the `configure` block, but didn't quite manage to get what I want
a) appends my config to the existing one
```groovy
configure { node ->
(node / 'healthMetrics') << 'com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric' {
nonRecursive true
}
}
```
b) errors out with `groovy.lang.MissingMethodException: No signature of method: groovy.util.Node.call() is applicable for argument types: (script$_run_closure1$_closure5$_closure15) values: [script$_run_closure1$_closure5$_closure15@274e33cb]`
```groovy
configure { node ->
(node / 'healthMetrics' / 'com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric') {
nonRecursive true
}
}
```
It's my first time using direct [xml manipulation](https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block#transforming-xml) like this, so maybe I'm just doing it wrong. Even if someone manages to point me in the right direction for the `configure` way, "official" support for this would of course still be the end goal here.
In my mind, this could just look something like
```groovy
multibranchPipelineJob('foo') {
healthMetrics {
worstChildHealthMetric {
nonRecursive(true)
}
}
}
```
Note that I'm also looking at [`PrimaryBranchHealthMetric.java`](https://github.com/jenkinsci/branch-api-plugin/blob/master/src/main/java/jenkins/branch/PrimaryBranchHealthMetric.java) but have no idea how that would relate to / integrate with this plugin and/or job-dsl
In a similar vein, I also found `properties / organizationChildHealthMetricsProperty`, but as far as I can understand, that's for nested folders (i.e. applies multibranch folders within an organization folder). Either way, I've tried the config from [this comment](https://github.com/jenkinsci/job-dsl-plugin/issues/2355#issuecomment-3607301004) aswell with no luck. (Like I said, probably because it's not the right option)
I _assume_ each plugin provides its own methods to job-dsl and that plugin just pulls it all together, which is why I'm raising my issue here. If this is the wrong place to ask (issue with job-dsl or multibranch pipelines), feel free to transfer this issue (that _should_ work within a github org).
### Upstream changes
n/a
### Are you interested in contributing this feature?
no
Contributor guide
Assessment
This issue has not been assessed yet.