It's all about the answers!

Ask a question

Update Build Definitions that match with a pattern


specting jazz (1122) | asked May 30 '12, 6:36 a.m.
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:

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("-------------------");

}
}

2 answers



permanent link
specting jazz (1122) | answered May 30 '12, 8:05 a.m.
I'm working with RTC 3.0

permanent link
specting jazz (1122) | answered May 30 '12, 9:23 a.m.
Finally I've got the solution!!!! :D

with the save method of ITeamBuildClient

Great!!!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.