File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\matrix\MatrixAggregator.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.matrix;
25
26 import hudson.ExtensionPoint;
27 import hudson.Launcher;
28 import hudson.model.BuildListener;
29 import hudson.tasks.BuildStep;
30 import hudson.tasks.Publisher;
31
32 import java.io.IOException;
33
34 /**
35 * Performs the aggregation of {@link MatrixRun} results
36 * into {@link MatrixBuild}.
37 *
38 * <p>
39 * {@link MatrixAggregator} is a transitive stateful mutable object.
40 * Unlike {@link Publisher}, it is not persisted. Instead, a fresh
41 * instance is created for each {@link MatrixBuild}, and various
42 * methods on this class are invoked in the event callback style
43 * as the build progresses.
44 *
45 * <p>
46 * The end result of the aggregation should be
47 * {@link MatrixBuild#addAction(Action) contributed as actions}.
48 *
49 * @author Kohsuke Kawaguchi
50 * @since 1.115
51 * @see MatrixAggregatable
52 */
53 public abstract class MatrixAggregator implements ExtensionPoint {
54 /**
55 * The build in progress. Never null.
56 */
57 protected final MatrixBuild build;
58
59 protected final Launcher launcher;
60 /**
61 * The listener to send the output to. Never null.
62 */
63 protected final BuildListener listener;
64
65 protected MatrixAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) {
66 this.build = build;
67 this.launcher = launcher;
68 this.listener = listener;
69 }
70
71 /**
72 * Called before the build starts.
73 *
74 * @return
75 * true if the build can continue, false if there was an error
76 * and the build needs to be aborted.
77 * @see BuildStep#prebuild(Build,BuildListener)
78 */
79 public boolean startBuild() throws InterruptedException, IOException {
80 return true;
81 }
82
83 /**
84 * Called whenever one run is completed.
85 *
86 * @param run
87 * The completed {@link MatrixRun} object. Always non-null.
88 * @return
89 * See {@link #startBuild()} for the return value semantics.
90 */
91 public boolean endRun(MatrixRun run) throws InterruptedException, IOException {
92 return true;
93 }
94
95 /**
96 * Called after all the {@link MatrixRun}s have been completed
97 * to indicate that the build is about to finish.
98 *
99 * @return
100 * See {@link #startBuild()} for the return value semantics.
101 */
102 public boolean endBuild() throws InterruptedException, IOException {
103 return true;
104 }
105 }
106