(→Add Random Test Results to a BuildLife)
|
(→AHPSCRIPTS-41)
|
Line 672: | |||
}</pre> | }</pre> | ||
+ | = Update Environment Properties for All Projects = | ||
+ | Here's a modification that runs form within AnthillPro. The environment is selected to be the current running environment and the other values are read out of properties (the environment could come from a property as well). | ||
+ | ==== AHPSCRIPTS-14 ==== | ||
+ | <pre>import com.urbancode.anthill3.main.client.AnthillClient; | ||
+ | import com.urbancode.anthill3.persistence.UnitOfWork; | ||
+ | import com.urbancode.anthill3.domain.project.*; | ||
+ | import com.urbancode.anthill3.domain.project.envprops.*; | ||
+ | import com.urbancode.anthill3.domain.servergroup.*; | ||
+ | import java.util.*; | ||
+ | variableName = PropertyLookup.get("variableName"); | ||
+ | newVariableValue = PropertyLookup.get("variableValue"); | ||
+ | boolean isSecure = Boolean.parseBoolean(PropertyLookup.get("isSecure")); | ||
+ | environment = EnvironmentLookup.getCurrent(); | ||
+ | // Project | ||
+ | Project[] projects = ProjectFactory.getInstance().restoreAll(); | ||
+ | // Loop through projects. If it has environment props for this, find the | ||
+ | // right one and change it as appropriate. | ||
+ | for (int i = 0; i < projects.length; i++) { | ||
+ | |||
+ | ProjectEnvironmentProperty[] envPropArray = environment.getEnvironmentPropertiesForProject(projects[i]); | ||
+ | boolean foundVariable = false; | ||
+ | for (int j = 0; j < envPropArray.length; j++) { | ||
+ | if (envPropArray[j].getName().equals(variableName)) { | ||
+ | foundVariable = true; | ||
+ | envPropArray[j].setValue(newVariableValue); | ||
+ | envPropArray[j].store(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if (!foundVariable) { | ||
+ | ProjectEnvironmentProperty newProp = new ProjectEnvironmentProperty(true); | ||
+ | |||
+ | newProp.setProject(projects[i]); | ||
+ | newProp.setServerGroup(environment); | ||
+ | newProp.setName(variableName); | ||
+ | newProp.setValue(newVariableValue); | ||
+ | newProp.setSetAsEnvProp(false); | ||
+ | newProp.setSecureValue(isSecure); | ||
+ | |||
+ | newProp.store(); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </pre> | ||
= Invoke Build of Another Project and Wait for Results = | = Invoke Build of Another Project and Wait for Results = | ||
This script needs to launch a build of another project that is not a dependency but treat it like it is. | This script needs to launch a build of another project that is not a dependency but treat it like it is. |