/
rebuild.groovy
91 lines (77 loc) · 3.59 KB
/
rebuild.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterValue
import hudson.matrix.AxisList
import hudson.matrix.Combination
import hudson.matrix.Layouter
import hudson.matrix.MatrixBuild
import hudson.matrix.MatrixProject
import hudson.model.ParametersDefinitionProperty
import hudson.plugins.matrix_configuration_parameter.MatrixCombinationsParameterDefinition
import lib.LayoutTagLib
import org.kohsuke.stapler.jelly.groovy.Namespace
l = namespace(LayoutTagLib)
t = namespace("/lib/hudson")
st = namespace("jelly:stapler")
f = namespace("lib/form")
nsProject = namespace("/hudson/plugins/matrix_configuration_parameter/taglib")
def valueIt = it;
MatrixProject project = request.findAncestorObject(MatrixProject.class);
MatrixBuild build = request.findAncestorObject(MatrixBuild.class);
if (project == null || build == null) {
//in case you are looking at a specific run, MatrixRun Ancestor will replace the MatrixBuild
set("escapeEntryTitleAndDescription", false);
f.entry(title: h.escape(valueIt.name), description: it.formattedDescription) {
// In the case the parameter is not defined in this project,
// sending parameters cause rebuild-plugin throws exception.
// Acts as if I'm not here.
text(_("Not applicable. Applicable only to multi-configuration projects."))
}
return;
}
AxisList axes = project.getAxes();
Layouter layouter = new Layouter<Combination>(axes) {
protected Combination getT(Combination c) {
return c;
}
};
def parameterDefinition = project.getProperty(ParametersDefinitionProperty.class).getParameterDefinition(valueIt.name);
if (!(parameterDefinition instanceof MatrixCombinationsParameterDefinition)) {
parameterDefinition = null;
}
drawParameterBody(parameterDefinition, f, valueIt, axes, project, build, layouter);
private void drawParameterBody(MatrixCombinationsParameterDefinition paramDef, Namespace f,valueIt,AxisList axes,MatrixProject project,MatrixBuild build,Layouter layouter) {
set("escapeEntryTitleAndDescription", false);
f.entry(title: h.escape(valueIt.name), description: it.formattedDescription) {
div(name: "parameter", class: "matrix-combinations-parameter") {
input(type: "hidden", name: "name", value: valueIt.getName())
nsProject.matrix(it: build, layouter: layouter) {
drawTableBall(p, project.axes, valueIt, project, build, layouter);
}
if (paramDef != null) {
nsProject.shortcut(parameter: paramDef, project: project, build: build);
}
}//div
}
}
private void drawTableBall(Combination combination,AxisList axes,matrixValue,MatrixProject project,MatrixBuild build,Layouter layouter) {
run = build.getRun(combination);
result = matrixValue.combinationExists(axes, combination);
if (run != null && result){
a(href:rootURL+"/"+run.getUrl()){
l.icon(class:"icon-md "+run.getIconColor().getIconClassName())
if (!layouter.x || !layouter.y) {
text(combination.toString(layouter.z))
}
}
span(class: "combination", "data-combination": combination.toIndex(axes)) {
f.checkbox(checked: true, name: "combinations", json: combination.toString());
}
} else {
l.icon(class:"icon-md icon-nobuilt")
if (!layouter.x || !layouter.y) {
text(combination.toString(layouter.z))
}
span(class: "combination", "data-combination": combination.toIndex(axes)) {
f.checkbox(checked: "false", name: "combinations", json: combination.toString())
}
}
}