Delete jenkins jobs having matching template

How to delete jobs on jenkins with "Data_jobs_" prefix? and also How do I disable all jobs with the "Data_jobs_server" prefix?

Does anyone know how to do this by going to / script page ??

+3


source to share


1 answer


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()
    }
}

      

+4


source







All Articles