How to find the latest Dependency easily in Anthillpro3 Remoting script

丶灬走出姿态 提交于 2019-12-25 04:48:16

问题


I want to Automate the process of Branch creation in our project.Below are the steps which are being done manually using the Anthill Web UI. In our Anthill we have around 250 Java projects whose workflows are named after their release names like RB-16.4.5.

Step 1: Copy the workflow of each project with current branch like RB-16.4.5.

Step 2: Edit the Workflow name to new Branch name like RB-16.4.6 and change the source URL to latest branch name like somelocation/branches/16.4.6/projects/ProjectA

Step 3: For many of the project we have added Dependents in Anthill.So we would want to update them with latest Branch projects.So what we do is that we delete the old dependencies with old Branch names like ProjectA RB-16.4.5 and add new dependencies by going to Administration TAB of the new Workflow created and Search for the new project with Folder name ProjectA RB-16.4.6

Now the code which i have written is working fine for the first two steps But am unable to find how i could write code for Step 3.Since am unable to figure out how to get the latest Dependency Project of the new workflow we created above. from Anthill documentation.We cannot set or change the name of Dependency to new one.

I have gone through the official Java Remoting API available at http://download.boulder.ibm.com/ibmdl/pub/software/rationalsdp/documentation/product_doc/UrbanCode/AnthillPro/remoting/api/index.html

AnthillClient client;
String currentBranch="RB-16.4.5";
String newBranch="RB-16.4.6";

UnitofWork uow=client.createUnitOfWork();

Folder[] allFolders=FolderFactory.getInstance().restoreAll();
Project[] myProjects={};

for(int i=0;i<allFolders.length;i++){
if(allFolders[i].getName().equals("MyPrjFolder")){
myProjects=allFolders[i].getProjects();
break;
}
//For each project copy the workflow and set New branch name & Source URL
for(int j=0;j<myProjects.length;j++){
 Workflow flow=WorkflowLookup.getForProjectAndName(myProjects[j],newBranch);

 Workflow newworkFlow=flow.duplicateForCopy(myProjects[j]);
 newworkFlow.setUnitOfWork(uow);
 newworkFlow.setName(newBranch);
 newworkFlow.setNew(true);
 newworkFlow.setActive(true);

 SvnSourceConfig svnConfig=
 (SvnSourceConfig)         newWorkFlow.getBuildProfile().getSourceConfig();
 SvnModule[] svnModule=svnConfig.getModuleArray();
 String sourceURL=svnModule[0].getUrl();
 svnModule[0].setUrl(sourceURL.replace(currentBranch,newBranch));

// Store the dependencies of old project branch  in a list
 Dependency   
 existingDependencies=flow.getBuildProfile().getAnthillDependencyArray();
 someList.add(existingDependencies);
 }


 /*Now how do i set the Dependencies for each Project with new Project of
  the new Branch if i have already stored the old dependecies of projects*/
// Code to create and add dependency should be something like 
// How do i get the newDependency value which refers to the Project under   new workflow created
 Dependency newDependency=null;
 newDependency=    Dependency.createDependency(existingDependencies[i].getDependent),newDependency.getDependency());

}


回答1:


How about a different approach ? Get the branch name as input from the end user ?



来源:https://stackoverflow.com/questions/38677098/how-to-find-the-latest-dependency-easily-in-anthillpro3-remoting-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!