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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2010, 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.model.Job;
27 import hudson.tasks.LogRotator;
28
29 import java.io.IOException;
30
31 /**
32 * {@link LogRotator} for {@link MatrixConfiguration},
33 * which discards the builds if and only if it's discarded
34 * in the parent.
35 *
36 * <p>
37 * Because of the serialization compatibility, we can't easily
38 * refactor {@link LogRotator} into a contract and an implementation.
39 *
40 * @author Kohsuke Kawaguchi
41 */
42 final class LinkedLogRotator extends LogRotator {
43 LinkedLogRotator(int artifactDaysToKeep, int artifactNumToKeep) {
44 super(-1, -1, artifactDaysToKeep, artifactNumToKeep);
45 }
46
47 /**
48 * @deprecated since 1.369
49 * Use {@link #LinkedLogRotator(int, int)}
50 */
51 LinkedLogRotator() {
52 super(-1, -1, -1, -1);
53 }
54
55 @Override
56 public void perform(Job _job) throws IOException, InterruptedException {
57 // Let superclass handle clearing artifacts, if configured:
58 super.perform(_job);
59 MatrixConfiguration job = (MatrixConfiguration) _job;
60
61 // copy it to the array because we'll be deleting builds as we go.
62 for( MatrixRun r : job.getBuilds().toArray(new MatrixRun[0]) ) {
63 if(job.getParent().getBuildByNumber(r.getNumber())==null)
64 r.delete();
65 }
66
67 if(!job.isActiveConfiguration() && job.getLastBuild()==null)
68 job.delete();
69 }
70 }
71