(→AHPSCRIPTS-66)
|
(→Dynamic Dependency Selection)
|
Line 273: | |||
}</pre> | }</pre> | ||
+ | = Double Dynamic Dependency Selection = | ||
+ | Script Notes: | ||
+ | * This scripted step searches all your projects for ones with a specific stamp (technically stamp pattern I think) and adds matching builds as dependencies. Only the most recent build of each project is added and the project will not add itself as a dependency. | ||
+ | *The idea is to identify some set of projects / applications / services that need to be deployed out together for a particular release. Each project would have a workflow that just assigns a release id to a stamp style dedicated to that purpose. So as a QA person or release engineer, I can approve specific builds for a release. | ||
+ | *A release manager would then run a workflow that includes this script. That would define a release set containing the builds flagged for this release. It could pull in the artifacts for the subprojects and package them, or just establish the dependency relationships for use in a "Run Workflow on Dependencies" step that runs the deployment workflow for each dependency in turn. | ||
+ | ==== AHPSCRIPTS-61 ==== | ||
+ | <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.*; | ||
+ | import java.util.*; | ||
+ | ///////////////////////////////////////////////////////////////////// | ||
+ | // CHANGE STAMP AND LOG TO REUSE THE SCRIPT // | ||
+ | // // | ||
+ | // STAMP_PROPERTY -- Name of workflow property identifying release // | ||
+ | // Logger passes in the name of the step. "Run Script" by default. // | ||
+ | ///////////////////////////////////////////////////////////////////// | ||
+ | final String STAMP_PROPERTY = "release id"; | ||
+ | private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger | ||
+ | ("Lookup Dependencies"); | ||
+ | //---------------------------------------------- | ||
+ | project = ProjectLookup.getCurrent(); | ||
+ | buildLife = BuildLifeLookup.getCurrent(); | ||
+ | stamp = PropertyLookup.getValue(STAMP_PROPERTY); | ||
+ | buildLifeSummaries = DashboardFactory.getInstance(). | ||
+ | getBuildLifeSummariesForProjectWithStamp(null, null, stamp, null, null); | ||
+ | log.info("Found " + buildLifeSummaries.length + " builds for stamp " + stamp); | ||
+ | // Great, we found candidates. Let's take the most recent for each project. | ||
+ | HashSet projectIds = new HashSet(); | ||
+ | |||
+ | for (int i = 0; i < buildLifeSummaries.length; i++) { | ||
+ | if (projectIds.contains(buildLifeSummaries[i].getProjectId())) { | ||
+ | log.warn("Found duplicates for " + buildLifeSummaries[i].getProjectName() | ||
+ | + ". Keeping only the most recent."); | ||
+ | } | ||
+ | else if (project.getId().equals(buildLifeSummaries[i].getProjectId())) { | ||
+ | log.warn("Found myself. This is at least the second assembly of " + | ||
+ | "deployables for this release."); | ||
+ | } | ||
+ | else { | ||
+ | // We found a target to deploy | ||
+ | projectIds.add(buildLifeSummaries[i].getProjectId()); | ||
+ | depBuildLife = BuildLifeFactory.getInstance(). | ||
+ | restore(buildLifeSummaries[i].getBuildLifeId()); | ||
+ | buildLife.addDependencyBuildLife(depBuildLife); | ||
+ | log.info("Adding: " + buildLifeSummaries[i].getProjectName() + " - " + | ||
+ | buildLifeSummaries[i].getWorkflowName() + " build: " + | ||
+ | buildLifeSummaries[i].getBuildLifeId() ); | ||
+ | } | ||
+ | } </pre> | ||
= Consolidate Reports of Dependency Projects & Publish Them in Parent Project Report = | = Consolidate Reports of Dependency Projects & Publish Them in Parent Project Report = | ||