Version Differences for Miscellaneous Scripts

(Add unknown SCM users as AHP users)
(Dynamic Dependency Selection)
Line 272:
   
  }</pre>    }</pre> 
       
    + = Consolidate Reports of Dependency Projects & Publish Them in Parent Project Report =  
       
    + Script Notes:  
    + * This is a script that will take logs published as reports for dependency projects and consolidate them so that they can be viewed in one location on the reports tab of the blanket project.  
    + * Here is a more efficient way of getting the entire dependency graph. This will not process the same build life more than once.  
    + :* <pre>Set buildDependencyBuildLivesSet(BuildLife buildLife) {  
    + Set result = new HashSet();  
    + buildDependencyBuildLivesSet(buildLife, result, new HashSet());  
    + return result;  
    + }  
       
    + buildDependencyBuildLivesSet(BuildLife buildLife, Set depSet, Set traversedSet) {  
    + if (!travesedSet.contains(buildLife)) {  
    + travesedSet.add(buildLife):  
    + CodestationCompatableBuildLife[] dependencyBuildLives = buildLife.getDependencyBuildLifeArray();  
    + for (int i = 0; i < dependencyBuildLives.length; i++) {  
    + CodestationCompatableBuildLife dependencyBuildLife = dependencyBuildLives[i];  
    + if (dependencyBuildLife instanceof BuildLife) {  
    + log.warn("DependencyBuildLife " + dependencyBuildLife.getName());  
    + depSet.add(dependencyBuildLife);  
    + buildDependencyBuildLivesSet((BuildLife) dependencyBuildLife, depSet, traversedSet));  
    + }  
    + }  
    + }  
    + } </pre>  
       
    + ==== AHPSCRIPTS-7 ====  
       
    + <pre>import com.urbancode.anthill3.runtime.scripting.helpers.BuildLifeLookup;  
    + import com.urbancode.anthill3.runtime.paths.PublishPathHelper;  
    + import com.urbancode.anthill3.domain.buildlife.BuildLife;  
    + import com.urbancode.anthill3.domain.workflow.WorkflowCase;  
    + import com.urbancode.devilfish.services.var.VarService;  
    + import com.urbancode.anthill3.domain.jobtrace.JobTrace;  
    + import com.urbancode.commons.fileutils.FileUtils;  
    + import com.urbancode.codestation2.domain.buildlife.CodestationCompatableBuildLife;  
    + import java.util.*;  
       
    + static final private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("ReportScript");  
       
    + final String REPORT_NAME = "LogReport";  
       
    + VarService vs = VarService.getInstance();  
       
    + void centrallyLocateLogsForBuildLife(BuildLife buildLife, String reportPath) {  
       
    + File reportDir = new File(reportPath + File.separator + buildLife.getProfile().getProject().getName().replace(" ", "_"));  
    + reportDir.mkdirs();  
    + log.warn("Report Path Dir" + reportDir.getAbsolutePath());  
       
    + WorkflowCase workflowCase = buildLife.getOriginatingWorkflow();  
    + JobTrace[] jobTraces = workflowCase.getJobTraceArray();  
       
    + for (int i = 0; i < jobTraces.length; i++) {  
    + String dependencyPath = PublishPathHelper.getInstance().getPublishPath(jobTraces[i], REPORT_NAME);  
    + log.warn("Dependency Path " + dependencyPath);  
    + dependencyPath = vs.resolve(dependencyPath);  
    + File dependencyReportDir = new File(dependencyPath);  
    + if (dependencyReportDir != null &&  
    + dependencyReportDir.exists() &&  
    + dependencyReportDir.isDirectory()) {  
    + log.warn("Copying reports from " + dependencyReportDir.getAbsolutePath() + " to " + reportDir.getAbsolutePath());  
    + FileUtils.copyFiles(dependencyReportDir, reportDir);  
    + }  
    + }  
    + }  
       
    + Set buildDependencyBuildLivesSet(BuildLife buildLife) {  
    + Set result = new HashSet();  
       
    + CodestationCompatableBuildLife[] dependencyBuildLives = buildLife.getDependencyBuildLifeArray();  
    + for (int i = 0; i < dependencyBuildLives.length; i++) {  
    + CodestationCompatableBuildLife dependencyBuildLife = dependencyBuildLives[i];  
    + if (dependencyBuildLife instanceof BuildLife) {  
    + log.warn("DependencyBuildLife " + dependencyBuildLife.getName());  
    + result.add(dependencyBuildLife);  
    + result.addAll(buildDependencyBuildLivesSet((BuildLife) dependencyBuildLife));  
    + }  
    + }  
       
    + return result;  
    + }  
       
       
    + BuildLife buildLife = BuildLifeLookup.getCurrent();  
       
    + String reportPath = PublishPathHelper.getInstance().getPublishPath(JobTraceLookup.getCurrent(), REPORT_NAME);  
    + reportPath = vs.resolve(reportPath);  
    + log.warn("Report Path " + reportPath);  
       
    + Set dependencyBuildLifeSet = buildDependencyBuildLivesSet(buildLife);  
    + Iterator itr = dependencyBuildLifeSet.iterator();  
       
    + while (itr.hasNext()) {  
    + BuildLife buildLife = (BuildLife) itr.next();  
    + centrallyLocateLogsForBuildLife(buildLife, reportPath);  
    + } </pre>