Version Differences for Miscellaneous Scripts

(Add unknown SCM users as AHP users)
(Add unknown SCM users as AHP users)
Line 216:
  } catch (IOException e) {    } catch (IOException e) { 
  }</pre>    }</pre> 
       
    + = Dynamic Dependency Selection =  
       
    + Script Notes:  
    + * This script is used to select only a subset of the dependencies. So if my project is dependent on the componets S1, S2, S3. This script empowers you to select only S1 and S3. It does this by looking for builds that have been stamped with some value passed into this workflow.  
    + * The relationships to S1, S2, and S3 can't be defined in the workflow running this script or else they'll be locked in at build time, so we use a separate "template" workflow that defines the base relationships. This script inspects that workflow to determine which build tracks produce candidates for dependency selection.  
    + * you will need to change the replace(String, String) to replace(Char, Char) if you are not running java 1.5, oops sorry.  
       
    + ==== AHPSCRIPTS-4 ====  
       
    + <pre>import com.urbancode.codestation2.domain.project.*;  
    + import com.urbancode.anthill3.domain.buildlife.*;  
    + import com.urbancode.anthill3.runtime.scripting.helpers.*;  
    + import com.urbancode.anthill3.dashboard.*;  
       
       
    + private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger  
    + ("ScriptEval");  
       
    + String TEMPLATE_WORKFLOW_NAME="All Dependencies (Most Recent)";  
       
    + project = ProjectLookup.getCurrent();  
    + buildLife = BuildLifeLookup.getCurrent();  
    + workflowArray = project.getOriginatingWorkflowArray();  
    + stamp = PropertyLookup.getValue("stamp");  
       
    + templateWorkflow = null;  
    + for (int i = 0; i < workflowArray.length; i++) {  
    + if (workflowArray[i].getName().equals(TEMPLATE_WORKFLOW_NAME)) {  
    + templateWorkflow = workflowArray[i];  
    + break;  
    + }  
    + }  
       
    + if (templateWorkflow == null) {  
    + throw new Exception("Could not find expected workflow on this project: " + TEMPLATE_WORKFLOW_NAME);  
    + }  
       
    + dependencyArray = templateWorkflow.getBuildProfile().getDependencyArray();  
    + log.error("Dependencies found in template: " + dependencyArray.length);  
    + for (int i = 0; i < dependencyArray.length; i++) {  
    + dep = dependencyArray[i].getDependency();  
    + if (dep instanceof AnthillProject) {  
    + buildProfile = dep.getBuildProfile();  
    + workflow = buildProfile.getWorkflow();  
    + depProject = buildProfile.getProject();  
    + buildLifeSummaries = DashboardFactory.getInstance().getBuildLifeSummariesForProjectWithStamp(depProject, workflow, stamp, null, null);  
    + log.info("Found " + buildLifeSummaries.length + " builds for stamp " + stamp + " on project " + depProject.getName() + " " + workflow.getName());  
    + // We found a build life matching the right stamp, let's add it as a dependency  
    + if (buildLifeSummaries.length > 0) {  
    + // take the most recent build matching that stamp.  
    + depBuildLife = BuildLifeFactory.getInstance().restore(buildLifeSummaries[0].getBuildLifeId());  
    + buildLife.addDependencyBuildLife(depBuildLife);  
    + }  
    + }  
    + }</pre>