Version Differences for Miscellaneous Scripts

(Dynamic Dependency Selection)
(Consolidate Reports of Dependency Projects & Publish Them in Parent Project Report)
Line 370:
  centrallyLocateLogsForBuildLife(buildLife, reportPath);    centrallyLocateLogsForBuildLife(buildLife, reportPath); 
  } </pre>    } </pre> 
       
    + = Export Project Configuration to XML =  
       
    + Script Notes:  
    + * Set this script up as an evaluate script step in an operational workflow within an operational project. You will then need to set up a property on the workflow called '''ProjectName''' to pass in the project you would like to export. Finally, this script's output will be placed in the ''%SERVER_HOME%\bin'' directory unless otherwise noted by setting a working directory.  
       
    + ==== AHPSCRIPTS-9 ====  
       
    + <pre>import org.w3c.dom.Document;  
    + import com.urbancode.anthill3.runtime.scripting.helpers.*;  
    + import com.urbancode.anthill3.domain.project.Project;  
    + import com.urbancode.anthill3.domain.project.ProjectFactory;  
    + import com.urbancode.anthill3.domain.xml.XMLImporterExporter;  
    + import com.urbancode.commons.xml.DOMUtils;  
    + import java.io.*;  
       
    + //Set a property on the operational workflow called 'ProjectName'  
    + //so that you can input which project name you want to run this  
    + //script on. Alternatively, you could remove the references to  
    + //a property and just substitute in a string.  
    + String PROJECT_NAME = PropertyLookup.getValue("ProjectName");  
       
    + //Restores the property and writes to a string  
    + Project project = ProjectFactory.getInstance().restoreForName(PROJECT_NAME);  
    + Document doc = XMLImporterExporter.exportXML(project, "project");  
    + String xmlString = DOMUtils.documentToString(doc);  
       
    + //Writes the xmlString to a file determined by the project name  
    + //and appends '.xml' to the export.  
    + FileWriter outFile = new FileWriter(PathHelper.makeSafe(PropertyLookup.getValue("ProjectName"))+".xml");  
    + BufferedWriter buffer = new BufferedWriter(outFile);  
    + PrintWriter out = new PrintWriter(buffer);  
    + out.println(xmlString);  
    + out.flush();  
    + out.close(); </pre>  
       
    + ==== Export Dependencies ====  
       
    + <pre>  
    + import org.w3c.dom.Document;  
    + import com.urbancode.anthill3.runtime.scripting.helpers.*;  
    + import com.urbancode.anthill3.domain.project.*;  
    + import com.urbancode.anthill3.domain.xml.XMLImporterExporter;  
    + import com.urbancode.anthill3.domain.xml.*;  
    + import com.urbancode.commons.xml.*;  
    + import com.urbancode.anthill3.domain.profile.*;  
    + import com.urbancode.anthill3.domain.workflow.*;  
    + import java.io.*;  
       
    + //Set a property on the operational workflow called 'ProjectName'  
    + //so that you can input which project name you want to run this  
    + //script on. Alternatively, you could remove the references to  
    + //a property and just substitute in a string.  
    + String PROJECT_NAME = PropertyLookup.getValue("ProjectName");  
       
    + //Restores the property and writes to a string  
    + Project project = ProjectFactory.getInstance().restoreForName(PROJECT_NAME);  
    + Document doc = XMLImporterExporter.exportXML(project, "project");  
    + String xmlString = DOMUtils.documentToString(doc);  
       
    + //Writes the xmlString to a file determined by the project name  
    + //and appends '.xml' to the export.  
    + DependencyXml depXml = new DependencyXml();  
    + String pDep = depXml.exportDependencies(project);  
       
    + FileWriter outFile = new FileWriter(PathHelper.makeSafe(PropertyLookup.getValue("ProjectName"))+"_dependencies.xml");  
    + BufferedWriter buffer = new BufferedWriter(outFile);  
    + PrintWriter out = new PrintWriter(buffer);  
    + out.println(pDep);  
    + out.flush();  
    + out.close(); </pre>