jenkins 编译所有任务

通过遍历任务可以批量触发符合规则的任务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pipeline {
agent {
label "some node"
}
stages {
stage("trigger build") {
steps {
script {
def jobs = getPipelineJobNames()
for ( job in jobs) {
build job: job, wait: false
}
}
}
}
}
}
@NonCPS
def getPipelineJobNames() {
Hudson.instance.getAllItems(org.jenkinsci.plugins.workflow.job.WorkflowJob)*.fullName
}