How do I programmatically create a release from a build?
I have both the build system toolkit as well as the Java Client Api. As part of my build I automatically execute a fairly thorough set of build verification tests. Assuming those tests pass, I want to automatically/programmatically create a release from the build, instead of manually doing it from the build results page.
Any ideas on how to do that or pointers to where I could look?
Thanks,
Al
Any ideas on how to do that or pointers to where I could look?
Thanks,
Al
One answer
Assuming you have an IBuildResult in hand, you can do something like this.
This is how the RTC UI does it.
IWorkItemClient workItemClient = (IWorkItemClient)
teamRepository.getClientLibrary(IWorkItemClient.class);
IBuildDefinition definition = (IBuildDefinition)
teamRepository.itemManager().fetchCompleteItem(buildResult.getBuildDefinition(),
IItemManager.REFRESH, null);
ITeamAreaHandle teamAreaHandle = definition.getTeamArea();
ITeamArea teamArea = (ITeamArea)
teamRepository.itemManager().fetchCompleteItem(teamAreaHandle,
IItemManager.REFRESH, null);
final IDeliverable deliverable =
workItemClient.createDeliverable(teamArea.getProjectArea(),"name of
release", null);
deliverable.setArtifact(buildResult);
deliverable.setCreationDate(new Timestamp(System.currentTimeMillis()));
deliverable.setName("name of release");
deliverable.setHTMLDescription(XMLString.createFromPlainText(definition.getId()
+ " " + buildResult.getLabel()));
deliverable.setFiltered(false);
workItemClient.saveDeliverable(deliverable, null);
---
Ryan Manwiller
Jazz Team
This is how the RTC UI does it.
IWorkItemClient workItemClient = (IWorkItemClient)
teamRepository.getClientLibrary(IWorkItemClient.class);
IBuildDefinition definition = (IBuildDefinition)
teamRepository.itemManager().fetchCompleteItem(buildResult.getBuildDefinition(),
IItemManager.REFRESH, null);
ITeamAreaHandle teamAreaHandle = definition.getTeamArea();
ITeamArea teamArea = (ITeamArea)
teamRepository.itemManager().fetchCompleteItem(teamAreaHandle,
IItemManager.REFRESH, null);
final IDeliverable deliverable =
workItemClient.createDeliverable(teamArea.getProjectArea(),"name of
release", null);
deliverable.setArtifact(buildResult);
deliverable.setCreationDate(new Timestamp(System.currentTimeMillis()));
deliverable.setName("name of release");
deliverable.setHTMLDescription(XMLString.createFromPlainText(definition.getId()
+ " " + buildResult.getLabel()));
deliverable.setFiltered(false);
workItemClient.saveDeliverable(deliverable, null);
---
Ryan Manwiller
Jazz Team