Version Differences for Remoting Specific Scripts

(AHPSCRIPTS-75)
(AHPSCRIPTS-74)
Line 752:
  ac = null;    ac = null; 
  ////////////////////////////////////////</pre>    ////////////////////////////////////////</pre> 
       
    + = Migrate All Workflows Using One Branch to Use Different Branch (CVS) =  
    + This script changes the branch that is being checked out from cvs to be a different branch. This helps teams that are using a release branching strategy where the branch their workflows are building changes with each release and this change effects every workflow in the stack.  
    + ==== AHPSCRIPTS-73 ====  
    + <pre>import com.urbancode.anthill3.main.client.AnthillClient;  
    + import com.urbancode.anthill3.persistence.UnitOfWork;  
    + import com.urbancode.anthill3.domain.profile.*;  
    + import com.urbancode.anthill3.domain.source.*;  
    + import com.urbancode.anthill3.domain.source.cvs.*;  
    + import com.urbancode.anthill3.domain.workflow.*;  
    + import com.urbancode.anthill3.domain.repository.cvsrepo.*;  
       
    + String serverHost = "localhost";  
    + int serverPort = 4567;  
    + String userName = "admin";  
    + String password = "admin";  
       
    + if (bsh.args.length != 6) {  
    + print("usage: <server> <port> <username> <password> <fromBranch> <toBranch>");  
    + throw new IllegalArgumentException("Incorrect number of arguments specified");  
    + }  
       
    + serverHost = bsh.args[0];  
    + serverPort = Integer.parseInt(bsh.args[1]);  
    + userName = bsh.args[2];  
    + password = bsh.args[3];  
       
    + String fromBranch = bsh.args[4];  
    + String toBranch = bsh.args[5];  
       
    + print("Migrating " + fromBranch + " to " + toBranch);  
       
    + // obtain connection to the Anthill server  
    + AnthillClient anthill = AnthillClient.connect(serverHost, serverPort,  
    + userName, password);  
       
    + // create a Unit of Work  
    + UnitOfWork uow = anthill.createUnitOfWork();  
       
    + // Workflow  
    + Workflow[] workflows = WorkflowFactory.getInstance().restoreAll();  
       
    + for (int i = 0; i < workflows.length; i++) {  
    + Workflow workflow = workflows[i];  
    + if (workflow != null && workflow.isOriginating()) {  
    + BuildProfile buildProfile = workflow.getBuildProfile();  
    + SourceConfig sourceConfig = buildProfile.getSourceConfig();  
    + if (sourceConfig instanceof CvsSourceConfig) {  
    + CvsSourceConfig cvsSourceConfig = (CvsSourceConfig) sourceConfig;  
    + CvsModule module = cvsSourceConfig.getModuleArray()[0];  
    + if (module.getBranch() != null && module.getBranch().equals(fromBranch)) {  
    + print("Changing Project:" + workflow.getProject().getName() + " Workflow:" + workflow.getName());  
    + module.setBranch(toBranch);  
    + }  
    + }  
    + }  
    + }  
       
    + uow.commitAndClose();</pre>