Search code examples
jenkinsjenkins-pluginsjenkins-cli

How to delete a view in Jenkins and automatically its jobs?


With Jenkins, if I delete a view, I want to delete the view's jobs also.

Is there a way to do it properly ?


Solution

  • Before deleting your view: in "Manage Jenkins"->"Script Console", run this script:

    Jenkins.instance.getView("MyView").items.each { item ->
        println "deleting $item.name"
        item.delete()
    }
    

    After that, the view will be empty -- delete it then.