I have around 100-120 jobs in one of the view called "Gradle Deploys" that I created in Jenkins. How can I disable all the jobs from Jenkins only from a given View / tab.
I tried the following groovy syntax to first just show all the jobs in a given view but it errors out.
jenkins = Hudson.instance
//The following works actually but gives a lot of info.
//println "----" + jenkins.instance.getView("Gradle Deploys").items
println "----" + jenkins.instance.getView("Gradle Deploys").items.each.getItems().print(it)
Once I get the list of just job names in a given view, I just have to use ".disable()" function in the above command and it'll work.
If I use the following code, it does what I want, but I'm looking for a one liner.
for (item in jenkins.instance.getView("Gradle Deploys").items) {
println("\nJob: $item.name")
item.disabled=true
}
To delete this view, go to "Manage Jenkins" > "Configure System" and change the selection in the "Default View" drop-down. You can't change the default view unless you already have another view created. Once you have changed to a new default view, you can delete the "All" view.
You should be able to just disable them all with:
jenkins.instance.getView("Gradle Deploys").items*.disabled = true
But if you want to print something out at the same time, you'll need an each
jenkins.instance.getView("Gradle Deploys").items.each { item ->
println "\nJob: $item.name"
item.disabled = true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With