コード例 #1
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);
 }