示例#1
0
 private RevisionState getLastState(final Run<?, ?> lastBuild) {
   if (lastBuild == null) {
     return null;
   }
   final RevisionState lastState = lastBuild.getAction(RevisionState.class);
   if (lastState != null && lastState.getBranch() == manifestBranch) {
     return lastState;
   }
   return getLastState(lastBuild.getPreviousBuild());
 }
示例#2
0
  @Override
  protected PollingResult compareRemoteRevisionWith(
      final AbstractProject<?, ?> project,
      final Launcher launcher,
      final FilePath workspace,
      final TaskListener listener,
      final SCMRevisionState baseline)
      throws IOException, InterruptedException {
    SCMRevisionState myBaseline = baseline;
    if (myBaseline == null) {
      // Probably the first build, or possibly an aborted build.
      myBaseline = getLastState(project.getLastBuild());
      if (myBaseline == null) {
        return PollingResult.BUILD_NOW;
      }
    }

    FilePath repoDir;
    if (destinationDir != null) {
      repoDir = workspace.child(destinationDir);
      if (!repoDir.isDirectory()) {
        repoDir.mkdirs();
      }
    } else {
      repoDir = workspace;
    }

    if (!checkoutCode(launcher, repoDir, listener.getLogger())) {
      // Some error occurred, try a build now so it gets logged.
      return new PollingResult(myBaseline, myBaseline, Change.INCOMPARABLE);
    }

    final RevisionState currentState =
        new RevisionState(
            getStaticManifest(launcher, repoDir, listener.getLogger()),
            manifestBranch,
            listener.getLogger());
    final Change change;
    if (currentState.equals(myBaseline)) {
      change = Change.NONE;
    } else {
      change = Change.SIGNIFICANT;
    }
    return new PollingResult(myBaseline, currentState, change);
  }