99import hudson .model .AbstractBuild ;
1010import hudson .model .AbstractProject ;
1111import hudson .model .Hudson ;
12- import hudson .model .Run ;
1312import hudson .scm .ChangeLogParser ;
1413import hudson .scm .NullChangeLogParser ;
1514import hudson .scm .PollingResult ;
@@ -118,20 +117,26 @@ public boolean requiresWorkspaceForPolling() {
118117 }
119118
120119 @ Override
121- public boolean pollChanges (final AbstractProject project ,
122- final Launcher launcher , final FilePath workspace ,
123- final TaskListener listener ) throws IOException ,
120+ public SCMRevisionState calcRevisionsFromBuild (
121+ final AbstractBuild <?, ?> project , final Launcher launcher ,
122+ final TaskListener listener ) throws IOException , InterruptedException {
123+ return null ;
124+ }
125+
126+ @ Override
127+ protected PollingResult compareRemoteRevisionWith (
128+ final AbstractProject <?, ?> project , final Launcher launcher ,
129+ final FilePath workspace , final TaskListener listener ,
130+ final SCMRevisionState state ) throws IOException ,
124131 InterruptedException {
125132 boolean change = false ;
126- final Run lastBuild = project .getLastBuild ();
127- if (lastBuild == null ) {
128- return true ;
129- }
130- final URLDateAction dates = lastBuild .getAction (URLDateAction .class );
131- if (dates == null ) {
132- return true ;
133+
134+ if (state == null || !(state instanceof URLDateAction )) {
135+ listener .getLogger ().println ("Changes not yet tracked with last build, triggering a new one" );
136+ return PollingResult .BUILD_NOW ;
133137 }
134138
139+ final URLDateAction dates = (URLDateAction ) state ;
135140 for (final URLTuple tuple : urls ) {
136141 final String urlString = tuple .getUrl ();
137142 try {
@@ -155,9 +160,9 @@ public boolean pollChanges(final AbstractProject project,
155160 + e .getMessage ());
156161 }
157162 }
158- return change ;
163+ return change ? PollingResult . BUILD_NOW : PollingResult . NO_CHANGES ;
159164 }
160-
165+
161166 public static final class URLTuple {
162167 private final String urlString ;
163168
@@ -225,19 +230,4 @@ protected FormValidation check() throws IOException,
225230 }
226231 }
227232
228- @ Override
229- public SCMRevisionState calcRevisionsFromBuild (
230- final AbstractBuild <?, ?> arg0 , final Launcher arg1 ,
231- final TaskListener arg2 ) throws IOException , InterruptedException {
232- return null ;
233- }
234-
235- @ Override
236- protected PollingResult compareRemoteRevisionWith (
237- final AbstractProject <?, ?> arg0 , final Launcher arg1 ,
238- final FilePath arg2 , final TaskListener arg3 ,
239- final SCMRevisionState arg4 ) throws IOException ,
240- InterruptedException {
241- return PollingResult .BUILD_NOW ;
242- }
243233}
0 commit comments