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

1 package hudson.scm;
2
3 import hudson.model.AbstractProject;
4 import hudson.model.TaskListener;
5 import hudson.Launcher;
6 import hudson.FilePath;
7
8 import java.io.Serializable;
9
10 /**
11 * Immutable object that represents the result of {@linkplain SCM#poll(AbstractProject, Launcher, FilePath, TaskListener, SCMRevisionState) SCM polling}.
12 *
13 * <p>
14 * This object is marked serializable just to be remoting friendly &mdash; Jenkins by itself
15 * doesn't persist this object.
16 *
17 * @author Kohsuke Kawaguchi
18 * @since 1.345
19 */
20 public final class PollingResult implements Serializable {
21 /**
22 * Baseline of the comparison.
23 * (This comes from either the workspace, or from the remote repository as of the last polling.
24 * Can be null.
25 */
26 public final SCMRevisionState baseline;
27
28 /**
29 * Current state of the remote repository. To be passed to the next invocation of the polling method.
30 * Can be null.
31 */
32 public final SCMRevisionState remote;
33
34 /**
35 * Degree of the change between baseline and remote. Never null.
36 * <p>
37 * The fact that this field is independent from {@link #baseline} and {@link #remote} are
38 * used to (1) allow the {@linkplain Change#INCOMPARABLE incomparable} state which forces
39 * the immediate rebuild, and (2) allow SCM to ignore some changes in the repository to implement
40 * exclusion feature.
41 */
42 public final Change change;
43
44 /**
45 * Degree of changes between the previous state and this state.
46 */
47 public enum Change {
48 /**
49 * No change. Two {@link SCMRevisionState}s point to the same state of the same repository / the same commit.
50 */
51 NONE,
52 /**
53 * There are some changes between states, but those changes are not significant enough to consider
54 * a new build. For example, some SCMs allow certain commits to be marked as excluded, and this is how
55 * you can do it.
56 */
57 INSIGNIFICANT,
58 /**
59 * There are changes between states that warrant a new build. Jenkins will eventually
60 * schedule a new build for this change, subject to other considerations
61 * such as the quiet period.
62 */
63 SIGNIFICANT,
64 /**
65 * The state as of baseline is so different from the current state that they are incomparable
66 * (for example, the workspace and the remote repository points to two unrelated repositories
67 * because the configuration has changed.) This forces Jenkins to schedule a build right away.
68 * <p>
69 * This is primarily useful in SCM implementations that require a workspace to be able
70 * to perform a polling. SCMs that can always compare remote revisions regardless of the local
71 * state should do so, and never return this constant, to let Jenkins maintain the quiet period
72 * behavior all the time.
73 * <p>
74 * This constant is not to be confused with the errors encountered during polling, which
75 * should result in an exception and eventual retry by Jenkins.
76 */
77 INCOMPARABLE
78 }
79
80 public PollingResult(SCMRevisionState baseline, SCMRevisionState remote, Change change) {
81 if (change==null) throw new IllegalArgumentException();
82 this.baseline = baseline;
83 this.remote = remote;
84 this.change = change;
85 }
86
87 public PollingResult(Change change) {
88 this(null,null,change);
89 }
90
91 public boolean hasChanges() {
92 return change.ordinal() > Change.INSIGNIFICANT.ordinal();
93 }
94
95 /**
96 * Constant to indicate no changes in the remote repository.
97 */
98 public static final PollingResult NO_CHANGES = new PollingResult(Change.NONE);
99
100 public static final PollingResult SIGNIFICANT = new PollingResult(Change.SIGNIFICANT);
101
102 /**
103 * Constant that uses {@link Change#INCOMPARABLE} which forces an immediate build.
104 */
105 public static final PollingResult BUILD_NOW = new PollingResult(Change.INCOMPARABLE);
106
107 private static final long serialVersionUID = 1L;
108 }
109