Enumerating through releases defined in a project area?
For the current project I'm working on, I've developed a custom Ant task (using the Plain Java client) to query the RTC server and produce a change log that details what change sets were included in a given build. I then take the file that I've created and post it to the build results as a log file.
My problem is this: we currently do a build every night, but I would like the change log to incorporate all change sets from the last build that we released to our test team. So, what I'm doing right now is setting the date and time of the last test build as a parameter in the ant task.
What I'd like to do in query the releases defined to the project area. Every time we release a build to the test team, I update the releases tab on the project area definition. I'd like to be able to enumerate through the list of releases, but I haven't seen any APIs/classes to do it.
Here is the code I'm using to select the change sets:
What I'd really like to be able to do is set the criteria.setModifiedAfter() field to the name or creation date of the last release I've defined. If someone could just point me in the right direction it would be appreciated.
My problem is this: we currently do a build every night, but I would like the change log to incorporate all change sets from the last build that we released to our test team. So, what I'm doing right now is setting the date and time of the last test build as a parameter in the ant task.
What I'd like to do in query the releases defined to the project area. Every time we release a build to the test team, I update the releases tab on the project area definition. I'd like to be able to enumerate through the list of releases, but I haven't seen any APIs/classes to do it.
Here is the code I'm using to select the change sets:
private List<IChangeSetHandle> getChangeSets(IComponent component, String sDateFrom) throws RTCExtensionException {
IChangeSetSearchCriteria criteria;
SimpleDateFormat format;
Date baseDate;
try {
//set the date as the baseline from which we want to gather
//all change set
format = new SimpleDateFormat("yyyyMMdd-hhmm");
baseDate = format.parse(sDateFrom);
// set the criteria for processing change sets
criteria = IChangeSetSearchCriteria.FACTORY.newInstance();
criteria.setComponent((IComponentHandle)component.getItemHandle());
criteria.setModifiedAfter(new Timestamp(baseDate.getTime()));
return myWorkspace.getManager().findChangeSets(criteria, 10000, myMonitor);
} catch (Exception e) {
throw new RTCExtensionException(e.getMessage(), e);
}
}
What I'd really like to be able to do is set the criteria.setModifiedAfter() field to the name or creation date of the last release I've defined. If someone could just point me in the right direction it would be appreciated.
3 answers
Never mind, I figured it out:
public void getDeliverables() throws RTCExtensionException {
IWorkItemClient workItemClient = (IWorkItemClient)myRepository.getClientLibrary(IWorkItemClient.class);
IProcessClientService processClient = (IProcessClientService)myRepository.getClientLibrary(IProcessClientService.class);
try {
URI uri = URI.create("System Director Network Manager".replaceAll(" ", "%20"));
IProjectArea projectArea = (IProjectArea)processClient.findProcessArea(uri, null, null);
if (projectArea == null) {
System.out.println("Project area not found.");
return;
}
ItemProfile<IDeliverable> profile = ItemProfile.<IDeliverable> createProfile(IDeliverable.ITEM_TYPE,
AuditablesHelper.AUDITABLE_SMALL_PROFILE).createExtension(
Arrays.asList(new String[] {IDeliverable.NAME_PROPERTY, IDeliverable.DESCRIPTION_PROPERTY,
IDeliverable.PROJECT_AREA_PROPERTY}));
List<IDeliverable> deliverables = workItemClient.findDeliverablesByProjectArea(
(IProjectAreaHandle)projectArea.getItemHandle(), true, (ItemProfile<IDeliverable>)profile,
myMonitor);
for (int x = 0; x < deliverables.size(); x++) {
System.out.println(deliverables.get(x).getName());
}
} catch (Exception e) {
throw new RTCExtensionException(e.getMessage(), e);
}
return;
}
ItemProfile<IDeliverable> profile =
ItemProfile.<IDeliverable
createProfile(IDeliverable.ITEM_TYPE,
AuditablesHelper.AUDITABLE_SMALL_PROFILE).createExtension(
Arrays.asList(new String[]
{IDeliverable.NAME_PROPERTY, IDeliverable.DESCRIPTION_PROPERTY,
IDeliverable.PROJECT_AREA_PROPERTY}));
If you want to avoid the internal AuditablesHelper, you could just write
profile=
IDeliverable.SMALL_PROFILE.createExtension(IDeliverable.DESCRIPTION_PROPERTY);
--
Regards,
Patrick
Jazz Work Item Team