|
This page lists scripts to make scripted workflow properties. These scripts were taken straight from the [https://bugs.urbancode.com/secure/IssueNavigator.jspa?reset=true&&pid=10110&sorter/field=issuekey&sorter/order=ASC public JIRA site]. Please note that some scripts may be ''snippets'' and '''probably WILL need''' modification to work properly for your situation. Treat these as templates that you can modify from. |
|
This page lists scripts to make scripted workflow properties. These scripts were taken straight from the [https://bugs.urbancode.com/secure/IssueNavigator.jspa?reset=true&&pid=10110&sorter/field=issuekey&sorter/order=ASC public JIRA site]. Please note that some scripts may be ''snippets'' and '''probably WILL need''' modification to work properly for your situation. Treat these as templates that you can modify from. |
|
|
+ |
= Select the Agent in Environment to Run on =
|
|
|
+ |
*Give the user the ability to select which agent the workflow should run on using a dynmic workflow property and a agent filter.
|
|
|
+ |
*Create a new Agent Filter script that will return all agents that are referenced in a property value. The property name I use is 'agents' which you can change. It should be the name of the workflow property you will add that allows them to be selected. Here is the script:
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.agent.Agent;
|
|
|
+ |
public Agent[] filter(Agent[] agents) {
|
|
|
+ |
agentNames = PropertyLookup.get("agents");
|
|
|
+ |
nameArray = agentNames.split(",");
|
|
|
+ |
agentList = new ArrayList();
|
|
|
+ |
for (int a=0; a<agents.length; a++) {
|
|
|
+ |
for (int n=0; n<nameArray.length; n++) {
|
|
|
+ |
if (agents[a].getName().equals(nameArray[n])) {
|
|
|
+ |
agentList.add(agents[a]);
|
|
|
+ |
agents = agentList.toArray(new Agent[agentList.size()]);
|
|
|
+ |
*On your workflow, create a multi-select property that is scripted. In my example, I name it 'agents' and the Agent Filter script needs to use the same name. It should be user overrideable and required. The script for value I used is:
|
|
|
+ |
<pre>import com.urbancode.anthill3.services.agent.AgentManager;
|
|
|
+ |
import com.urbancode.anthill3.domain.agent.AgentFactory;
|
|
|
+ |
endpoints = AgentManager.getInstance().getOnLineEndpointArray(environment);
|
|
|
+ |
values = new String[endpoints.length];
|
|
|
+ |
for (int i=0; i<endpoints.length; i++) {
|
|
|
+ |
agent = AgentFactory.getInstance().restoreByEndpoint(endpoints[i]);
|
|
|
+ |
values[i] = agent.getName();
|