hudson.model.AbstractProject.getLastCompletedBuild()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中hudson.model.AbstractProject.getLastCompletedBuild()方法的一些代码示例,展示了AbstractProject.getLastCompletedBuild()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractProject.getLastCompletedBuild()方法的具体详情如下:
包路径:hudson.model.AbstractProject
类名称:AbstractProject
方法名:getLastCompletedBuild

AbstractProject.getLastCompletedBuild介绍

暂无

代码示例

代码示例来源:origin: org.jvnet.hudson.plugins/testng-plugin

public AbstractBuildAction getLastCompletedBuildAction() {
 for (AbstractBuild<?, ?> build = getProject().getLastCompletedBuild(); build != null; build = build.getPreviousBuild()) {
   final AbstractBuildAction action = build.getAction(getBuildActionClass());
   if (action != null) {
    return action;
   }
 }
 return null;
}

代码示例来源:origin: org.hudsonci.plugins/instant-messaging

@Override
protected CharSequence getMessageForJob(AbstractProject<?, ?> job) {
  AbstractBuild<?, ?> build = job.getLastCompletedBuild();
  if (build == null) {
    // No builds
    return job.getFullDisplayName() + " has never been built";
  }   
  AbstractTestResultAction<?> tests = build.getTestResultAction();
  if (tests == null) {
    // no test results associated with this job
    return job.getFullDisplayName() + ": latest build contains no test results";
  }
  StringBuilder listing = new StringBuilder(String.format("%s build #%s had %s of %s tests fail\n", job.getFullDisplayName(), build.getNumber(), tests.getFailCount(), tests.getTotalCount()));
  
  listing.append("\n");
  List<CaseResult> failedTests = tests.getFailedTests();
  for (CaseResult result : failedTests) {
    listing.append(String.format("%s failed in %ss\n", result.getFullName(), result.getDuration()));
  }
  return listing;
}

代码示例来源:origin: jenkinsci/instant-messaging-plugin

@Override
protected CharSequence getMessageForJob(AbstractProject<?, ?> job) {
  AbstractBuild<?, ?> build = job.getLastCompletedBuild();
  if (build == null) {
    // No builds
    return job.getFullDisplayName() + " has never been built";
  }   
  AbstractTestResultAction<?> tests = build.getAction(AbstractTestResultAction.class);
  if (tests == null) {
    // no test results associated with this job
    return job.getFullDisplayName() + ": latest build contains no test results";
  }
  StringBuilder listing = new StringBuilder(String.format("%s build #%s had %s of %s tests fail\n", job.getFullDisplayName(), build.getNumber(), tests.getFailCount(), tests.getTotalCount()));
  
  listing.append("\n");
  List<? extends TestResult> failedTests = tests.getFailedTests();
  for (TestResult result : failedTests) {
    listing.append(String.format("%s failed in %ss\n", result.getFullName(), result.getDuration()));
  }
  return listing;
}

代码示例来源:origin: jenkinsci/testlink-plugin

/**
 * If number of builds hasn't changed and if checkIfModified() returns true, no need to regenerate the graph.
 * Browser should reuse it's cached image
 * 
 * @param req
 * @param res
 * @return true, if new image does NOT need to be generated, false otherwise
 */
private boolean newGraphNotNeeded(final StaplerRequest req, StaplerResponse res) {
  boolean newGraphNotNeeded = false;
  Calendar t = getProject().getLastCompletedBuild().getTimestamp();
  Integer prevNumBuilds = requestMap.get(req.getRequestURI());
  int numBuilds = getProject().getBuilds().size();
  // change null to 0
  prevNumBuilds = prevNumBuilds == null ? 0 : prevNumBuilds;
  if (prevNumBuilds != numBuilds) {
    requestMap.put(req.getRequestURI(), numBuilds);
  }
  if (requestMap.keySet().size() > 10) {
    // keep map size in check
    requestMap.clear();
  }
  if (prevNumBuilds == numBuilds && req.checkIfModified(t, res)) {
    /*
     * checkIfModified() is after '&&' because we want it evaluated only if number of builds is different
     */
    newGraphNotNeeded = true;
  }
  return newGraphNotNeeded;
}

代码示例来源:origin: jenkinsci/copyartifact-plugin

AbstractBuild<?,?> upstreamBuild = upstreamProject.getLastCompletedBuild();
upstreamBuild != null;
upstreamBuild = upstreamBuild.getPreviousCompletedBuild()

代码示例来源:origin: org.jvnet.hudson.main/maven3-plugin

/**
   * Copied from {@link hudson.tasks.ArtifactArchiver}.
   */
  private void deleteOldBuildArtifacts() {
    AbstractBuild<?, ?> b = build.getProject().getLastCompletedBuild();
    Result bestResultSoFar = Result.NOT_BUILT;
    while (b != null) {
      if (b.getResult().isBetterThan(bestResultSoFar)) {
        bestResultSoFar = b.getResult();
      }
      else {
        // remove old artifacts
        File ad = b.getArtifactsDir();
        if (ad.exists()) {
          muxlog.info("Deleting old Maven artifacts from {}", b.getDisplayName());
          try {
            Util.deleteRecursive(ad);
          }
          catch (IOException e) {
            muxlog.error("Failed to delete old Maven artifacts", e);
          }
        }
      }
      b = b.getPreviousBuild();
    }
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

@Override
public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
  if(latestOnly) {
    AbstractBuild<?,?> b = build.getProject().getLastCompletedBuild();
    Result bestResultSoFar = Result.NOT_BUILT;
    while(b!=null) {
      if (b.getResult().isBetterThan(bestResultSoFar)) {
        bestResultSoFar = b.getResult();
      } else {
        // remove old artifacts
        File ad = b.getArtifactsDir();
        if(ad.exists()) {
          listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName()));
          try {
            Util.deleteRecursive(ad);
          } catch (IOException e) {
            e.printStackTrace(listener.error(e.getMessage()));
          }
        }
      }
      b = b.getPreviousBuild();
    }
  }
  return true;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

@Override
public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
  if(latestOnly) {
    AbstractBuild<?,?> b = build.getProject().getLastCompletedBuild();
    Result bestResultSoFar = Result.NOT_BUILT;
    while(b!=null) {
      if (b.getResult().isBetterThan(bestResultSoFar)) {
        bestResultSoFar = b.getResult();
      } else {
        // remove old artifacts
        File ad = b.getArtifactsDir();
        if(ad.exists()) {
          listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName()));
          try {
            Util.deleteRecursive(ad);
          } catch (IOException e) {
            e.printStackTrace(listener.error(e.getMessage()));
          }
        }
      }
      b = b.getPreviousBuild();
    }
  }
  return true;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

@Override
public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
  if (latestOnly) {
    AbstractBuild<?, ?> b = build.getProject().getLastCompletedBuild();
    Result bestResultSoFar = Result.NOT_BUILT;
    while (b != null) {
      if (b.getResult().isBetterThan(bestResultSoFar)) {
        bestResultSoFar = b.getResult();
      } else {
        // remove old artifacts
        File ad = b.getArtifactsDir();
        if (ad.exists()) {
          listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName()));
          try {
            Util.deleteRecursive(ad);
          } catch (IOException e) {
            e.printStackTrace(listener.error(e.getMessage()));
          }
        }
      }
      b = b.getPreviousBuild();
    }
  }
  return true;
}

代码示例来源:origin: hudson/hudson-2.x

@Override
public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
  if(latestOnly) {
    AbstractBuild<?,?> b = build.getProject().getLastCompletedBuild();
    Result bestResultSoFar = Result.NOT_BUILT;
    while(b!=null) {
      if (b.getResult().isBetterThan(bestResultSoFar)) {
        bestResultSoFar = b.getResult();
      } else {
        // remove old artifacts
        File ad = b.getArtifactsDir();
        if(ad.exists()) {
          listener.getLogger().println(Messages.ArtifactArchiver_DeletingOld(b.getDisplayName()));
          try {
            Util.deleteRecursive(ad);
          } catch (IOException e) {
            e.printStackTrace(listener.error(e.getMessage()));
          }
        }
      }
      b = b.getPreviousBuild();
    }
  }
  return true;
}

代码示例来源:origin: org.jvnet.hudson.plugins/testng-plugin

public void doGraphMap(StaplerRequest req,
    StaplerResponse rsp) throws IOException {
 Calendar t = getProject().getLastCompletedBuild().getTimestamp();
 if (req.checkIfModified(t, rsp)) {
   return; // up to date
 }
 DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataSetBuilder =
  new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
 //TODO: optimize by using cache
 populateDataSetBuilder(dataSetBuilder);
 ChartUtil.generateClickableMap(req, rsp, GraphHelper.createChart(req, dataSetBuilder.build()),
      getGraphWidth(), getGraphHeight());
}

代码示例来源:origin: org.jvnet.hudson.plugins/subversion

AbstractBuild<?, ?> lastCompletedBuild = project.getLastCompletedBuild();
if (lastCompletedBuild != null) {
  if (repositoryLocationsNoLongerExist(lastCompletedBuild, listener)) {

代码示例来源:origin: org.hudsonci.plugins/subversion

final AbstractBuild<?, ?> lastCompletedBuild = project.getLastCompletedBuild();
if (lastCompletedBuild != null) {
  if (repositoryLocationsNoLongerExist(lastCompletedBuild, listener)) {

代码示例来源:origin: org.jvnet.hudson.plugins/testng-plugin

/**
* Generates the graph that shows test pass/fail ratio
* @param req -
* @param rsp -
* @throws IOException -
*/
public void doGraph(StaplerRequest req,
          StaplerResponse rsp) throws IOException {
 if (GraphHelper.isGraphUnsupported()) {
   GraphHelper.redirectWhenGraphUnsupported(rsp, req);
   return;
 }
 Calendar t = getProject().getLastCompletedBuild().getTimestamp();
 if (req.checkIfModified(t, rsp)) {
   return; // up to date
 }
 DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataSetBuilder =
    new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
 populateDataSetBuilder(dataSetBuilder);
 ChartUtil.generateGraph(req, rsp, GraphHelper.createChart(req, dataSetBuilder.build()),
      getGraphWidth(), getGraphHeight());
}

相关文章

微信公众号

最新文章

更多

AbstractProject类方法