public PollingResult poll ( TaskListener listener ) { SCM scm = getScm ( ) ; if ( scm == null ) { listener . getLogger ( ) . println ( Messages . AbstractProject_NoSCM ( ) ) ; return NO_CHANGES ; } if ( ! isBuildable ( ) ) { listener . getLogger ( ) . println ( Messages . AbstractProject_Disabled ( ) ) ; return NO_CHANGES ; } SCMDecisionHandler veto = SCMDecisionHandler . firstShouldPollVeto ( this ) ; if ( veto != null ) { listener . getLogger ( ) . println ( Messages . AbstractProject_PollingVetoed ( veto ) ) ; return NO_CHANGES ; } R lb = getLastBuild ( ) ; if ( lb == null ) { listener . getLogger ( ) . println ( Messages . AbstractProject_NoBuilds ( ) ) ; return isInQueue ( ) ? NO_CHANGES : BUILD_NOW ; } if ( pollingBaseline == null ) { R success = getLastSuccessfulBuild ( ) ; // if we have a persisted baseline, we'll find it by this for ( R r = lb ; r != null ; r = r . getPreviousBuild ( ) ) { SCMRevisionState s = r . getAction ( SCMRevisionState . class ) ; if ( s != null ) { pollingBaseline = s ; break ; } if ( r == success ) break ; // searched far enough } // NOTE-NO-BASELINE: // if we don't have baseline yet, it means the data is built by old Hudson that doesn't set the baseline // as action, so we need to compute it. This happens later. } try { SCMPollListener . fireBeforePolling ( this , listener ) ; PollingResult r = _poll ( listener , scm ) ; SCMPollListener . firePollingSuccess ( this , listener , r ) ; return r ; } catch ( AbortException e ) { listener . getLogger ( ) . println ( e . getMessage ( ) ) ; listener . fatalError ( Messages . AbstractProject_Aborted ( ) ) ; LOGGER . log ( Level . FINE , "Polling " + this + " aborted" , e ) ; SCMPollListener . firePollingFailed ( this , listener , e ) ; return NO_CHANGES ; } catch ( IOException e ) { Functions . printStackTrace ( e , listener . fatalError ( e . getMessage ( ) ) ) ; SCMPollListener . firePollingFailed ( this , listener , e ) ; return NO_CHANGES ; } catch ( InterruptedException e ) { Functions . printStackTrace ( e , listener . fatalError ( Messages . AbstractProject_PollingABorted ( ) ) ) ; SCMPollListener . firePollingFailed ( this , listener , e ) ; return NO_CHANGES ; } catch ( RuntimeException e ) { SCMPollListener . firePollingFailed ( this , listener , e ) ; throw e ; } catch ( Error e ) { SCMPollListener . firePollingFailed ( this , listener , e ) ; throw e ; } }
Checks if there s any update in SCM and returns true if any is found .