(→AHPSCRIPTS-92)
|
(→AHPSCRIPTS-93)
|
Line 1420: | |||
e.printStackTrace(commandOutput); | e.printStackTrace(commandOutput); | ||
}</pre> | }</pre> | ||
+ | = Retrieve Stamp From Dependent Project so it is Passed as Property = | ||
+ | * This script assumes that some Project A, is dependent on some Project B. This script would be placed in an Evaluate Script Step, on a Generic Build Job. The script, looks up the most recent stamp value for Project B, and then saves the stamp as a BuildRequest Property. This allows the property to be passed/referenced by using the format | ||
+ | ** ${property: stampValue} | ||
+ | ==== AHPSCRIPTS-15 ==== | ||
+ | <pre>import com.urbancode.anthill3.domain.buildlife.*; | ||
+ | import com.urbancode.anthill3.runtime.scripting.helpers.*; | ||
+ | import com.urbancode.codestation2.domain.buildlife.CodestationCompatableBuildLife ; | ||
+ | import com.urbancode.codestation2.domain.project.*; | ||
+ | import java.util.ArrayList ; | ||
+ | import java.lang.Object; | ||
+ | import com.urbancode.anthill3.persistence.UnitOfWork; | ||
+ | import com.urbancode.anthill3.domain.buildrequest.BuildRequestStatusEnum; | ||
+ | import com.urbancode.anthill3.domain.buildrequest.RequestSourceEnum ; | ||
+ | import com.urbancode.anthill3.domain.persistent.Handle; | ||
+ | import com.urbancode.anthill3.domain.persistent.Persistent; | ||
+ | import com.urbancode.anthill3.domain.buildrequest.*; | ||
+ | UnitOfWork uow = UnitOfWork.getCurrent (); | ||
+ | static final String PROJECT_NAME = "Project B"; | ||
+ | //Get most current buildlife. | ||
+ | BuildLife blife = BuildLifeLookup.getCurrent(); | ||
+ | BuildRequest br = BuildRequestLookup.getCurrent(); | ||
+ | //Get dependency Array | ||
+ | CodestationCompatableBuildLife[] dArray =blife.getDependencyBuildLifeArray(); | ||
+ | String stamp = null; | ||
+ | for (int i = 0; i < dArray.length && stamp == null; i++) { | ||
+ | if (dArray[i].getCodestationProject() != null && | ||
+ | dArray[i].getCodestationProject() instanceof AnthillProject) { | ||
+ | AnthillProject project = (AnthillProject) | ||
+ | dArray[i].getCodestationProject(); | ||
+ | String temp = project.getBuildProfile ().getProject().getName(); | ||
+ | if (temp.equals(PROJECT_NAME)){ | ||
+ | stamp = dArray[i].getLatestStampValue(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | br.setProperty("Stamp_Value", stamp); | ||
+ | uow.commit();</pre> |