Update Build Definitions that match with a pattern
Hello,
I need update the properties of some Builds Definitions which ID match with a pattern.
I've wrote a program that find the Build Definitions and get the properties that I want to update by means a working copy,
but the problem is How can I save the changes in the Build Definition Object?
Here is the Program:
I need update the properties of some Builds Definitions which ID match with a pattern.
I've wrote a program that find the Build Definitions and get the properties that I want to update by means a working copy,
but the problem is How can I save the changes in the Build Definition Object?
Here is the Program:
IBuildDefinitionQueryModel BuildDefs_QueryModel = IBuildDefinitionQueryModel.ROOT;
IItemQuery query = IItemQuery.FACTORY.newInstance(BuildDefs_QueryModel);
query.filter(BuildDefs_QueryModel.id()._like(query.newStringArg()));
String[] parameters = new String[] { pattern };
IProgressMonitor monitor = new NullProgressMonitor();
ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
IItemQueryPage queryPage = buildClient.queryItems(query, parameters, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, monitor);
if (queryPage.getSize() == 0) {
System.out.println("Zero builds Definions found with pattern '" + pattern + "'");
} else {
System.out.println("Found " + queryPage.getSize() + " builds with pattern '" + pattern + "':");
List<?> buildResults = teamRepository.itemManager().fetchCompleteItems(queryPage.getItemHandles(), IItemManager.DEFAULT, monitor);
for (Object result : buildResults) {
IBuildDefinition buildDef = (IBuildDefinition) result;
System.out.println("Build: "+ buildDef.getId());
System.out.println("\t\tfetchDestination: "+ buildDef.getProperty("team.scm.fetchDestination"));
IBuildDefinition WorkCopy_buildDef = (IBuildDefinition) buildDef.getWorkingCopy();
WorkCopy_buildDef.setProperty("team.scm.fetchDestination", "My value for TEST");
System.out.println("-------------------");
}
}