Is it possible to change the content of a snapshot created by a build result during the build?
Hi,
I have a customer who is trying to change the content of snapshot created by a Build result.
The use case is that we have N component in the stream and we create some jar,war and ear packages with those components. But only 3 of those components will contain a package(ear,war,etc...). So we like to take a snapshot of those 3 components at the end the build and attach it to the actual Build Result. So whenever somebody open the build result, he/she will see only the components that have a dowloadable package.
Or which way would it be better to implement such a case? We thought about removing the uncessary components from BuildUser's workspace by using scm command in build.xml so the snapshot will only contain our desired component but didnt work.
Is it possible to do this kind of operations or not? I believe RTC wouldn't allow us to manipulate that snapshot.
2 answers
As Nick commented:
but there's currently no way of associating an arbitrary snapshot with the build result in the same way as the original snapshot
We wrote an Ant task that allows one to associate a snapshot to a build result. The task works, but once we started using the task we started experiencing this temporarily missing snapshot problem. EDIT: The issue has been resolved and the code below was updated to correct the issue. In certain cases, we associate the same snapshot to more than one build result (e.g. rebuild scenarios). The first time we associate the snapshot to the build result, all works fine. But, subsequent attempts sometimes fail where the server tells us that the item is no longer available. After some time, later attempts for the same item will work. Perhaps our Ant task is putting the snapshot into a temporary bad state?
The body of the Ant task is:
IBaselineSet snapshot = getSnapshot(this.snapshotUUID, getTeamRepository(), getProgressMonitor());
addSnapshotContributionToBuild(snapshot, getBuildResult(
IBuildResult.PROPERTIES_COMPLETE), getTeamRepository(), getProgressMonitor());
The body of the Ant task uses these two methods:
private IBaselineSet getSnapshot(String snapshotUuid, ITeamRepository teamRepository, IProgressMonitor progressMonitor)
throws TeamRepositoryException {IBaselineSetHandle baselineSetHandle = (IBaselineSetHandle)
IBaselineSet.ITEM_TYPE.createItemHandle(UUID.valueOf(snapshotUuid), null);return (IBaselineSet) teamRepository.itemManager().fetchCompleteItem(
baselineSetHandle, IItemManager.REFRESH, progressMonitor);
}
public void addSnapshotContributionToBuild(IBaselineSet snapshot,
IBuildResult buildResult, ITeamRepository teamRepository,
IProgressMonitor progressMonitor)
throws TeamRepositoryException {IBuildResultContribution contribution =
BuildItemFactory.createBuildResultContribution();contribution.setExtendedContributionTypeId(
ScmConstants.EXTENDED_DATA_TYPE_ID_BUILD_SNAPSHOT);
contribution.setImpactsPrimaryResult(false);
contribution.setLabel(NLS.bind(
AntMessages.TeamAcceptTask_SNAPSHOT_CONTRIBUTION_LABEL,
snapshot.getName()));
contribution.setExtendedContribution(snapshot);ITeamBuildClient buildClient = ClientFactory.getTeamBuildClient(teamRepository);
buildClient.addBuildResultContribution(buildResult, contribution,
progressMonitor);
}