删除具有匹配模式的jenkins作业(Delete jenkins jobs having the matching pattern)

如何删除前缀为“Data_jobs_”的jenkins上的作业? 以及如何禁用所有具有前缀“Data_jobs_server”的作业?

任何人都知道如何通过去/脚本页面?

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 ??

最满意答案

以下应该有效:

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

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

                    
                     
          

更多推荐