Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete jenkins jobs having the matching pattern

Tags:

jenkins

jobs

How to delete jobs on jenkins having the prefix "Data_jobs_" ? and How to disable all jobs having prefix "Data_jobs_server" ?

Anyone know how to do this by going /script page ??

like image 391
Naveen Kumar Avatar asked May 29 '15 14:05

Naveen Kumar


1 Answers

The following should work:

for (job in jenkins.model.Jenkins.theInstance.getProjects()) {
    if (job.name.startsWith("Data_jobs_"))  {
        job.delete()
    }
    else if (job.name.startsWith("Data_jobs_server"))  {
        job.disable()
    }
}
like image 78
Vadim Landa Avatar answered Sep 30 '22 16:09

Vadim Landa