Jenkins获取所有job

 

import jenkins.model.*

//定义函数,get all pipeline jobs.
@NonCPS
def getPipelineJobNames() {
Hudson.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob)*.fullName 
}

node {
//调用函数 
println getPipelineJobNames()

//Get all jobs.
jenkins.model.Jenkins.instance.getJobNames().findAll{ name -> println name }


def jobs = jenkins.model.Jenkins.instance.getJobNames()
def matchjobs = jobs.findAll{ name -> name =~ /(A|D|H)\w*/ }
println matchjobs

}

 

posted on 2020-08-04 14:33  momingliu11  阅读(2173)  评论(0编辑  收藏  举报