// set max folder depth to fix - e.g. 2 will fix root and one subfolder level def maxDepth = 2 // try dry run first, set false to apply changes def dryRun = true
def folders = Jenkins.instance.getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class) folders.each{ folder -> // check if folder is deeper than max depth def depthReached = false def parent = folder.getParent() for (i = 1; i <= maxDepth; i++) { if (!(parent instanceof com.cloudbees.hudson.plugins.folder.Folder)) { // top level reached break } if (i==maxDepth) { // level > max depth, do not consider this folder depthReached = true } else { parent = parent.getParent() } }
if (!depthReached) { println "Checking folder $folder.name..." folder.healthMetrics.each{ metric -> if (!(metric instanceof com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric)) { println "- ${dryRun?'Would remove':'Removing'} ${metric.class.simpleName} from ${folder.name}" if (!dryRun) { folder.healthMetrics.remove(metric) folder.save() } } } } } return null
How would you do this in non-enterprise Jenkins? I was going to go rooting around to see if I could find the non-enterprise classes to replace, but that kinda scares me.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 4: unable to resolve class com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric
@ line 4, column 29.
if (!(metric instanceof com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric))
I presumed it was because I didn't have the cloudbees enterprise version.
Which seems like it might be a renamed version of the same thing, and that was detected by the script but I don't know if that's the right thing to remove. When I remove it the column with the weather remains.
On a second look, this class is indeed defined in the CloudBees proprietary plugin. What you can try is to remove this condition completely and let script remove all the Health Metrics.
I don't see a clear answer on how to disable this for non-enterprise installations. I have the Cloudbees Folder plugin installed and that doesn't appear to have the classes detailed here. Thanks!
Unfortunately the script supplied above did not remove ANY of the weather columns on any of our masters. I see above where it explains it stops the updating, but what it the point of having a Weather column that is out of date?
"The only caveat of such a change is that the weather column will always report Folders as Healthy." is inaccurate. After using the Cloudbees supplied code, the weather will always report whatever the last status was when the metric was removed. So it could be permanently Healthy or Permanently Bad.
Secondarily, it would be very helpful if we could configure the "default" All view that folders are created with to:
Not look like this:
Put the build button leftmost where it is easier to find. Not include Weather Not include "Favorites" Not include "Built On" Not include "# Issues"
And finally, I'd like to understand the impact that the "Last (success/failure/duration)" times have on Jenkins master loads. If those are lightweight, I'd keep them, otherwise we need to lose them unless explicitly added to a view.
Comments
13 comments
Hi, thanks for the hint, this really helps.
If you only want to remove the health metrics from top level folder, you can add
So i.e. the script then is
Similarly, we could check for a certain folder depth level.
Here's my improved script with
Have fun!
How would you do this in non-enterprise Jenkins? I was going to go rooting around to see if I could find the non-enterprise classes to replace, but that kinda scares me.
Hi Chris-lee,
The script only requires that you have the CloudBees Folder plugin installed and this plugin is open source. It should therefore work on Jenkins LTS.
As written the script executed gives me this:
I presumed it was because I didn't have the cloudbees enterprise version.
I looked for the source and found "https://github.com/jenkinsci/cloudbees-folder-plugin/blob/master/src/main/java/com/cloudbees/hudson/plugins/folder/health/WorstChildHealthMetric.java"
Which seems like it might be a renamed version of the same thing, and that was detected by the script but I don't know if that's the right thing to remove. When I remove it the column with the weather remains.
On a second look, this class is indeed defined in the CloudBees proprietary plugin. What you can try is to remove this condition completely and let script remove all the Health Metrics.
To rollback:
Hello, I followed the instruction to go to a folder configuration page and I don't see anything under Health metrics.
But I am still seeing the weather column (see the attachment). Any ideas why?
Thanks
Junyi

Hi Junyi,
This will stop the weather column from constantly refreshing on all folders and the jobs within them.
It does not remove the icon.
I hope this makes sense.
I don't see a clear answer on how to disable this for non-enterprise installations. I have the Cloudbees Folder plugin installed and that doesn't appear to have the classes detailed here. Thanks!
I have an LTS versiob of jenkins with cloudbees-folder installed.
I am using it on a Github Folder (Github Branch source Plugin)
The problem that
Joe, Chen
The updated script should cover both of your use cases.
We have 10 Jenkins masters ranging from


CloudBees Jenkins Enterprise 2.176.4.3-rolling (the latest)
to
CloudBees Jenkins Enterprise 2.164.2.1-rolling (an old soon to be retired master)
Unfortunately the script supplied above did not remove ANY of the weather columns on any of our masters. I see above where it explains it stops the updating, but what it the point of having a Weather column that is out of date?
"The only caveat of such a change is that the weather column will always report Folders as Healthy." is inaccurate. After using the Cloudbees supplied code, the weather will always report whatever the last status was when the metric was removed. So it could be permanently Healthy or Permanently Bad.
Secondarily, it would be very helpful if we could configure the "default" All view that folders are created with to:
Not look like this:
Put the build button leftmost where it is easier to find.
Not include Weather
Not include "Favorites"
Not include "Built On"
Not include "# Issues"
And finally, I'd like to understand the impact that the "Last (success/failure/duration)" times have on Jenkins master loads. If those are lightweight, I'd keep them, otherwise we need to lose them unless explicitly added to a view.
Please sign in to leave a comment.