Updating Work Items included in a build
Hi All,
this is my first post to Jazz.net, so please excuse me if this is the wrong forum or it's been solved before.
I'm just beginning work on automating our manual build process and the core of our process looks like this:
label codebase
accept latest changes to a build workspace
compile and deploy code to an Integration environment
update work items which contributed to the build to a new Status (to let developers and testers know to perform sanity and functional testing)
Using JBE and ANT, I can run builds and the snapshots that generates are fine for recording purposes, but I'm at a loss as to how to touch the work items. I imagine I'll have to be coding a custom ant task or similar in order to achieve this, but I thought I'd ask in case anyone has done something similar, or could point me in the right direction.
If it helps, we're currently on RTC 2, but are planning to upgrade to 3 in the near future.
Thanks very much
Barny
this is my first post to Jazz.net, so please excuse me if this is the wrong forum or it's been solved before.
I'm just beginning work on automating our manual build process and the core of our process looks like this:
label codebase
accept latest changes to a build workspace
compile and deploy code to an Integration environment
update work items which contributed to the build to a new Status (to let developers and testers know to perform sanity and functional testing)
Using JBE and ANT, I can run builds and the snapshots that generates are fine for recording purposes, but I'm at a loss as to how to touch the work items. I imagine I'll have to be coding a custom ant task or similar in order to achieve this, but I thought I'd ask in case anyone has done something similar, or could point me in the right direction.
If it helps, we're currently on RTC 2, but are planning to upgrade to 3 in the near future.
Thanks very much
Barny
3 answers
Hi All,
this is my first post to Jazz.net, so please excuse me if this is the wrong forum or it's been solved before.
I'm just beginning work on automating our manual build process and the core of our process looks like this:
label codebase
accept latest changes to a build workspace
compile and deploy code to an Integration environment
update work items which contributed to the build to a new Status (to let developers and testers know to perform sanity and functional testing)
Using JBE and ANT, I can run builds and the snapshots that generates are fine for recording purposes, but I'm at a loss as to how to touch the work items. I imagine I'll have to be coding a custom ant task or similar in order to achieve this, but I thought I'd ask in case anyone has done something similar, or could point me in the right direction.
If it helps, we're currently on RTC 2, but are planning to upgrade to 3 in the near future.
Thanks very much
Barny
Hi,
I'm more familiar with the Build component Ant tasks, and we don't have one in the Build component that will modify the work items. Maybe someone else reading this knows of one in another component. If you do go the route of creating your own Ant task, this topic has some information about using the API to update a work item.
Brent Ulbricht
RTC Build Lead
Brent, thanks very much for the reply. I've got a number of source code examples of doing similar things and I'm now digging into how all the objects hang together.
I think any further questions probably belong in the Extending RTC forum
thanks again
Barny
Hi Barny,
code to create a link to a build result would be:
IBuildResult result........
ILinkManager linkManager= (ILinkManager) teamRepository.getClientLibrary(ILinkManager.class);
IReference source = IReferenceFactory.INSTANCE.createReferenceToItem(buildresult, sourceComment);
IItemReference source= IReferenceFactory.INSTANCE.createReferenceToItem(workitemHandle);
ILinkFactory.INSTANCE.createLink(BuildLinkTypes.INCLUDED_WORK_ITEMS, source, target);
linkManager.saveLink(link, monitor);
You can find the source, I grabbed the code below from the WorkitemPublisher class, if you set your environment up like described int the Extensions workshop: https://jazz.net/library/article/634
Please note, if you develop for Plain Java API, you can setup the project as plugin project, then add the Library and use the PDE tools to locate references. For deployment you would leave out the plugin.xml
Not sure if you still need to save the modified work item. Here would be some code for that too:
IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.SMALL_PROFILE, null);
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null);
try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText(summary));
IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}
} finally {
wcm.disconnect(workItem);
}
System.out.println("Modified work item: " + workItem.getId() + ".");