コード例 #1
0
  private BuildState createBuildState(MultiJobProject project) {

    MultiJobBuild lastBuild = project.getLastBuild();
    MultiJobBuild previousBuild = lastBuild == null ? null : lastBuild.getPreviousBuild();
    MultiJobBuild lastSuccessfulBuild = project.getLastSuccessfulBuild();
    MultiJobBuild lastFailedBuild = project.getLastFailedBuild();
    return new BuildState(
        project.getName(),
        previousBuild == null ? 0 : previousBuild.getNumber(),
        lastBuild == null ? 0 : lastBuild.getNumber(),
        lastSuccessfulBuild == null ? 0 : lastSuccessfulBuild.getNumber(),
        lastFailedBuild == null ? 0 : lastFailedBuild.getNumber());
  }
コード例 #2
0
 @SuppressWarnings("rawtypes")
 private void addMultiProject(
     MultiJobProject parent,
     MultiJobProject project,
     BuildState buildState,
     int nestLevel,
     String phaseName,
     List<TopLevelItem> out) {
   out.add(new ProjectWrapper(parent, project, buildState, nestLevel));
   List<Builder> builders = project.getBuilders();
   for (Builder builder : builders) {
     int phaseNestLevel = nestLevel + 1;
     if (builder instanceof MultiJobBuilder) {
       MultiJobBuilder reactorBuilder = (MultiJobBuilder) builder;
       List<PhaseJobsConfig> subProjects = reactorBuilder.getPhaseJobs();
       String currentPhaseName = reactorBuilder.getPhaseName();
       PhaseWrapper phaseWrapper = new PhaseWrapper(phaseNestLevel, currentPhaseName);
       out.add(phaseWrapper);
       for (PhaseJobsConfig projectConfig : subProjects) {
         TopLevelItem tli = Hudson.getInstance().getItem(projectConfig.getJobName());
         if (tli instanceof MultiJobProject) {
           MultiJobProject subProject = (MultiJobProject) tli;
           BuildState jobBuildState = createBuildState(buildState, project, subProject);
           phaseWrapper.addChildBuildState(jobBuildState);
           addMultiProject(
               project, subProject, jobBuildState, phaseNestLevel + 1, currentPhaseName, out);
         } else {
           Job subProject = (Job) tli;
           if (subProject == null) continue;
           BuildState jobBuildState = createBuildState(buildState, project, subProject);
           phaseWrapper.addChildBuildState(jobBuildState);
           addSimpleProject(project, subProject, jobBuildState, phaseNestLevel + 1, out);
         }
       }
     }
   }
 }
コード例 #3
0
 @SuppressWarnings({"rawtypes"})
 private BuildState createBuildState(
     BuildState parentBuildState, MultiJobProject multiJobProject, Job project) {
   int previousBuildNumber = 0;
   int lastBuildNumber = 0;
   int lastSuccessBuildNumber = 0;
   int lastFailureBuildNumber = 0;
   MultiJobBuild previousParentBuild =
       multiJobProject.getBuildByNumber(parentBuildState.getPreviousBuildNumber());
   MultiJobBuild lastParentBuild =
       multiJobProject.getBuildByNumber(parentBuildState.getLastBuildNumber());
   MultiJobBuild lastParentSuccessBuild =
       multiJobProject.getBuildByNumber(parentBuildState.getLastSuccessBuildNumber());
   MultiJobBuild lastParentFailureBuild =
       multiJobProject.getBuildByNumber(parentBuildState.getLastFailureBuildNumber());
   if (previousParentBuild != null) {
     List<SubBuild> subBuilds = previousParentBuild.getSubBuilds();
     for (SubBuild subBuild : subBuilds) {
       if (subBuild.getJobName().equals(project.getName())) {
         previousBuildNumber = subBuild.getBuildNumber();
       }
     }
   }
   if (lastParentBuild != null) {
     List<SubBuild> subBuilds = lastParentBuild.getSubBuilds();
     for (SubBuild subBuild : subBuilds) {
       if (subBuild.getJobName().equals(project.getName())) {
         lastBuildNumber = subBuild.getBuildNumber();
       }
     }
   }
   if (lastParentSuccessBuild != null) {
     List<SubBuild> subBuilds = lastParentSuccessBuild.getSubBuilds();
     for (SubBuild subBuild : subBuilds) {
       if (subBuild.getJobName().equals(project.getName())) {
         AbstractBuild build = (AbstractBuild) project.getBuildByNumber(subBuild.getBuildNumber());
         if (build != null && Result.SUCCESS.equals(build.getResult())) {
           lastSuccessBuildNumber = subBuild.getBuildNumber();
           break;
         } else {
           lastParentSuccessBuild =
               multiJobProject.getBuildByNumber(parentBuildState.getPreviousBuildNumber());
         }
       }
     }
   }
   if (lastParentFailureBuild != null) {
     List<SubBuild> subBuilds = lastParentFailureBuild.getSubBuilds();
     for (SubBuild subBuild : subBuilds) {
       if (subBuild.getJobName().equals(project.getName())) {
         AbstractBuild build = (AbstractBuild) project.getBuildByNumber(subBuild.getBuildNumber());
         if (build != null && Result.FAILURE.equals(((AbstractBuild) build).getResult())) {
           lastFailureBuildNumber = subBuild.getBuildNumber();
           break;
         } else {
           lastParentFailureBuild =
               multiJobProject.getBuildByNumber(parentBuildState.getPreviousBuildNumber());
         }
       }
     }
   }
   return new BuildState(
       project.getName(),
       previousBuildNumber,
       lastBuildNumber,
       lastSuccessBuildNumber,
       lastFailureBuildNumber);
 }