Skip to content

Instantly share code, notes, and snippets.

@paladin-dranser
Last active September 24, 2020 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paladin-dranser/02fe0f32a4bd04ccf843df7fcae759b2 to your computer and use it in GitHub Desktop.
Save paladin-dranser/02fe0f32a4bd04ccf843df7fcae759b2 to your computer and use it in GitHub Desktop.
Jenkins: Groovy script to delete empty views
/**
* This script deletes empty views
*/
import jenkins.model.Jenkins
import hudson.model.View
Jenkins instance = Jenkins.get()
ArrayList<View> views = instance.getViews()
views.each { View view ->
if (!view.items) {
instance.deleteView(view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment