-
Notifications
You must be signed in to change notification settings - Fork 11
/
AC_RefHelper_findBuildsOnRunParam.groovy
43 lines (39 loc) · 1.37 KB
/
AC_RefHelper_findBuildsOnRunParam.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*** BEGIN META {
"name" : "AC_RefHelper_findBuildsOnRunParam",
"comment" : "Returns a formatted HTML list of build href_links related by a common run type build parameter whose value is defined by the user.",
"parameters" : [ 'vName','vValue', 'vSearchSpace','vShow'],
"core": "1.593",
"authors" : [
{ name : "Ioannis Moutsatsos" }
]
} END META**/
/*
vSearchSpace: Required; A comma delimited list of Job names
vName : Required; The common parameter name
vValue : Required; parameter value to match
vShow : Flag (on/off) indicating whether to display links
*/
import jenkins.model.*;
jenkinsURL=jenkins.model.Jenkins.instance.getRootUrl()
def options=[] //by default we add the PARAMETER VALUE; this is the parent data set KEY
def htmlRefs=""
if(vShow=='on'){
jobNames=vSearchSpace.split(',')
jobNames.each{ job->
job=job.trim()
if (jenkins.model.Jenkins.instance.getItem(job)!=null){
jenkins.model.Jenkins.instance.getItem(job).getBuilds().each{
commonParam=it.getEnvironment(null).getAt(vName)
if (commonParam==vValue && it.result.toString()=='SUCCESS'){
uc_key=job+'#'+it.number
uc_value="(${it.id})_${it.getDisplayName()}:${it.getDescription()!=null?it.getDescription():''}"
htmlRefs=htmlRefs+"<a href=\"${jenkinsURL}job/$job/${it.number}\">$uc_value</a> <p>"
}
}
}
} //end each JobNames
return htmlRefs
}
else{
return '<hr/>'
}