我试图将所有工作都放在一个文件夹中
Jobs = input( id: 'userInput', message: 'Select the job', parameters: [ [$class: 'ChoiceParameterDefinition', choices: "????", description: 'Properties', name: 'jobs'] ])
我应该选择什么才能获得文件夹X中的所有工作?
答案 0 :(得分:0)
这是使用脚本控制台的一种方法:
import com.cloudbees.hudson.plugins.folder.Folder
def folderName = "test"
def allJobs= hudson.model.Hudson.getInstance().getItems()
for(int i=0; i<allJobs.size(); i++){
def job = allJobs[i]
if(job instanceof hudson.model.Project && job .getLastBuild() != null ){
processJob(job)
}else if(job instanceof Folder){
processFolderByName(job)
}
}
void processFolderByName(Item folder){
if(folder.getFullName().contains(folderName))
processFolder(folder)
}
void processFolder(Item folder){
//println "Processing Folder -"+folder.getFullName()
folder.getItems().each{
if(it instanceof com.cloudbees.hudson.plugins.folder.AbstractFolder){
processFolder(it)
}else{
processJob(it)
}
}
}
void processJob(Item job){
println job.getFullName()
// you can do operations like enable to disable
// job.disable()
}