It's all about the answers!

Ask a question

Is it possible to change the content of a snapshot created by a build result during the build?


Canberk Akduygu (99237071) | asked Sep 17 '12, 4:10 p.m.
retagged Jun 09 '13, 11:44 a.m. by Morten Madsen (3032341)

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



permanent link
Kirk Vogen (1271317) | answered Dec 07 '12, 11:27 a.m.
edited Dec 19 '12, 11:02 a.m.

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);
}




permanent link
Nick Edgar (6.5k711) | answered Sep 18 '12, 2:30 p.m.
JAZZ DEVELOPER
edited Sep 18 '12, 2:31 p.m.
Hi Canberk,

Currently JBE creates the snapshot after changes are accepted into the build workspace, but before the main phase of the build is run.  Snapshots are not mutable (except for changing their name).

You could use the SCM CLI to create a new snapshot, but there's currently no way of associating an arbitrary snapshot with the build result in the same way as the original snapshot.  You could possibly use the linkPublisher Ant task to associate a resource URL for the snapshot with the build result, which would show up on the External Links page of the build result editor.  Clicking it would open the snapshot in the snapshot editor.  The URL would have to be of the form: RTC_SERVER/resource/itemOid/com.ibm.team.scm.BaselineSet/SNAPSHOT_UUID.


Comments
Canberk Akduygu commented Oct 01 '12, 4:50 p.m. | edited Oct 02 '12, 9:29 a.m.

Hi Nick,

Thanks for the answer. linkpublisher is a good method. I am not that familiar with SCM command line but I know that we can give a name to the snapshot while creating it. So we have a name for the custom snapshot but I was wondering how we can get the UUID of this custom snapshot in ant so we can use linkpublisher.

Thanks in advance


Nick Edgar commented Oct 02 '12, 9:32 a.m.
JAZZ DEVELOPER

 You would need to specify -u y on the command line to have it generate UUIDs in the output, then parse that out, set it as an environment variable, and then bring that in to Ant using the property Ant task.  I realize this involves a lot of duct tape and baling wire, unfortunately.  Since 4.0, the SCM CLI supports JSON output as well.  For an intro to the SCM CLI and how to use it for this kind of scripting, see https://jazz.net/library/article/1031



Rachel Biderman commented Feb 09 '14, 3:28 p.m.

Hi Nick,

We have the same issue and there is still no support for it.
We are updating the build version in source files during the build and deliver it later to the stream (if build succeeded) and would like the snapshot to be applied including these version files changes, any suggestions?
since build snapshot can't be controlled when to be applied, and new snapshot can't be associated with the build result (and replace the original snapshot), i am out of ideas.
Thanks
Rachel


Nick Edgar commented Feb 10 '14, 1:06 p.m.
JAZZ DEVELOPER

Hi Rachel, the situation hasn't changed. The only recourse for now is to use the SCM CLI to create a new snapshot, and publish a link to it as a regular link contribution, as suggested above.

Your answer


Register or to post your answer.