Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Generating a WorkItem for a BVT: Included In Builds

Hi,

this is my first posting here.

I am currently writing a command to allow an RTC workitem to be creating after a BVT process is finished, allowing all the BVT information be stored and subscribers notified. This command is part of a refurbishment of the existing BVT process to eliminate certain manual sections.

I cannot believe how straightforward it has been to develop this using the RTC SDK.

There is one final enhancement to the command that I would like to make: to add the changesets that have been included in the build. I have been going through the forums for this information in the chance that someone else had posted about it, but to no avail.

I am at the stage now where I have all the workitems that are included in the build. I can get the changesets for the workitems, but not filtered down for the specific IBuildResult.

Would anyone have an idea of how I can filter the changesets for an IBuildResult? :idea:

Finbarr
Dev Engineer

0 votes



One answer

Permanent link
Hi,

this is my first posting here.

I am currently writing a command to allow an RTC workitem to be creating after a BVT process is finished, allowing all the BVT information be stored and subscribers notified. This command is part of a refurbishment of the existing BVT process to eliminate certain manual sections.

I cannot believe how straightforward it has been to develop this using the RTC SDK.

There is one final enhancement to the command that I would like to make: to add the changesets that have been included in the build. I have been going through the forums for this information in the chance that someone else had posted about it, but to no avail.

I am at the stage now where I have all the workitems that are included in the build. I can get the changesets for the workitems, but not filtered down for the specific IBuildResult.

Would anyone have an idea of how I can filter the changesets for an IBuildResult? :idea:

Finbarr
Dev Engineer


The key here is to remember that if the Jazz SCM pre-build participant is run with the build, it will create a snapshot and associate it to the build result. If you want every change set, then the snapshot will allow you to get this. However I'm assuming you want only the new change sets that went into the build. You can think of this as (current_build_snapshot) - (previous_build_snapshot) = change sets that went into the new build (the difference).

For example, here is how you can fetch the snapshot (called an IBaselineSet) associated to a build result.



IBaselineSet baselineSet = null;

ITeamBuildClient client = (ITeamBuildClient) getTeamRepository().getClientLibrary(ITeamBuildClient.class);
IBuildResultContribution[] snapshotContribution = client.getBuildResultContributions(buildResultHandle,
new String[] { ScmConstants.EXTENDED_DATA_TYPE_ID_BUILD_SNAPSHOT }, monitor);

if (snapshotContribution.length > 0) {
IBaselineSetHandle baselineSetHandle = (IBaselineSetHandle) snapshotContribution[0].getExtendedContribution();
baselineSet = (IBaselineSet) getTeamRepository().itemManager().fetchCompleteItem(baselineSetHandle,
IItemManager.REFRESH, monitor);


Now you'll want to compare the two snapshots...

if (fCurrentBuildSnapshot != null && fPreviousBuildSnapshot != null) {
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repository);
IChangeHistorySyncReport snapshotComparison = wm.compareBaselineSets(fCurrentBuildSnapshot, fPreviousBuildSnapshot, null, monitor);
}


Now you can use this IChangeHistorySyncReport and collect all the incoming/outgoing change sets to give you the results you want.


{
...
Map<ITeamRepository, Map<UUID>> changeSetsToAdd = new HashMap<ITeamRepository, Map<UUID>>();

IChangeHistorySyncReport snapshotComparison = (IChangeHistorySyncReport) element;
List outgoing = snapshotComparison.outgoingChangeSets();
if (outgoing.size() > 0) {
for (Object object : outgoing) {
if (object instanceof IChangeSetHandle) {
IChangeSetHandle changeSet = (IChangeSetHandle) object;
if (changeSet.getOrigin() != null && changeSet.getOrigin() instanceof ITeamRepository) {
ITeamRepository repo = (ITeamRepository) changeSet.getOrigin();
addChangeSet(changeSetsToAdd, repo, changeSet);
}
}
}
}
List incoming = snapshotComparison.incomingChangeSets();
if (incoming.size() > 0) {
for (Object object : incoming) {
if (object instanceof IChangeSetHandle) {
IChangeSetHandle changeSet = (IChangeSetHandle) object;
if (changeSet.getOrigin() != null && changeSet.getOrigin() instanceof ITeamRepository) {
ITeamRepository repo = (ITeamRepository) changeSet.getOrigin();
addChangeSet(changeSetsToAdd, repo, changeSet);
}
}
}
}
...
}

private void addChangeSet(Map<ITeamRepository, Map<UUID>> changeSetsMap, ITeamRepository repo, IChangeSetHandle changeSet) {
Map<UUID> currentChangeSets = null;
if (changeSetsMap.containsKey(repo)) {
currentChangeSets = changeSetsMap.get(repo);
}
if (currentChangeSets == null) {
currentChangeSets = new HashMap<UUID>(1);
}
currentChangeSets.put(changeSet.getItemId(), changeSet);
changeSetsMap.put(repo, currentChangeSets);
}

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: Mar 23 '12, 7:55 a.m.

Question was seen: 5,029 times

Last updated: Mar 23 '12, 7:55 a.m.

Confirmation Cancel Confirm