How do you deliver the snapshot created by a build to the stream?
Daniel Reilly (143●16●20)
| asked Jan 20 '15, 11:27 p.m.
edited May 30 '16, 7:12 p.m. by David Lafreniere (4.8k●7) We are using EE dependency builds which do not have the post-build option to deliver the snapshot.
I wrote an ant task that uses the api to do the deliver, but nothing happens -- no errors, no messages, no delivery. With the CLI you have to add -o option to make it work. Do I need something special using the API to duplicate the -o option? This will make the CLI do the delivery: <!-- ScmDeliverSnapshot Macro --> <macrodef name="ScmDeliverSnapshot">But, I can't use this with EE or JBE on zOS. CLI doesn't like the parms, must be backleveled. Here's the deliver code which does not deliver: // Search for stream IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance().setKind(IWorkspaceSearchCriteria.STREAMS); // Verify one stream if (streamWorkspaceHandles.size() == 0) { The syncReport.outgoingBaselines() = 3 before and after code executes. Completes without any message saying why deliver failed. |
Accepted answer
I got this to work using a JBE on zos unix system by changing macro to use <ant line=...> format: <!-- ScmDeliverSnapshot Macro -->
Still would like to know how to get API to handle situations like this though. djr Ralph Schoon selected this answer as the correct answer
Comments I have these examples: https://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/
|
3 other answers
I suspect the delivery is succeeding silently because there aren't any outgoing change sets. The build accepted all of the change sets into the build workspace when it started, so the body of your delivery loop will never run. #2 below is relevant for fixing this.
I have some comments about your code:
Also: you may want to change the snapshot owner, so that it appears in the list of snapshots for the stream.
Comments
Daniel Reilly
commented Jan 30 '15, 9:50 p.m.
I can add another check in for > 1. UUID is inconvient in this case and the code has to handle any input stream, so hard-coding is out. The snapshot I want to deliver is the one created by the build when accept incoming changes is on and it is not delivered by the deliver(). Using the CLI you have to use the -o to get it to work, nothing else works. I did figure out how to get that to work on zos unix (needed to change to <arg line=>), but that has to be a separate build executed in a JBE. I'll post updated ant code. I don't think #2 in my answer is clear. I'll try to do a better job explaining it:
Assuming your code runs after the build workspace has accepted the changes from the stream, the body of your loop will never run. This is because the build workspace has the exact same change sets as your stream, so
syncReport.outgoingChangeSets()
will alway return an empty list. Instead of looping over the change sets, you should run on the list of components in the sync report and deliver the outgoing baselines.
Incidentally: IIRC, delivering change sets individually like this may not work in all situations because the change sets aren't ordered in the sync report. The code may attempt to deliver a change set that builds on another outgoing change set that hasn't been delivered yet.
|
I was also struggling with a similar problem with incoming baselines and change sets and it's really important to understand that:
1) if you're dealing with changeHistorySyncReport.incomingBaselines() after a IChangeHistorySyncReport with WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO then you've to consider ONLY the change sets from changeHistorySyncReport.incomingChangeSetsAfterBasis() because changeHistorySyncReport.incomingChangeSets() gives you ALL the Change Sets, even those already pointed by the baselines
2) you may accept ONLY 1 baseline per component so you may not do all in a single shot
sourceWorkspaceConnection.accept(
AcceptFlags.DEFAULT,
targetWorkspaceConnection,
changeHistorySyncReport,
incomingBaselineHandles,
incomingChangeSetAfterBasisHandles,
progressMonitor);
|
Reading the notes from Evan you could end up with a code like this where you cycle for every component of the source workspace
IChangeHistorySyncReport changeHistorySyncReport = sourceFlowNodeConnection.compareTo( targetFlowNodeConnection, WorkspaceComparisonFlags.INCLUDE_BASELINE_INFO | WorkspaceComparisonFlags.INCLUDE_EMPTY_BASELINES, Collections.EMPTY_LIST, /*excludedComponents*/ progressMonitor); List<IComponentHandle> componentHandles = changeHistorySyncReport.localComponents(); //FOR EVERY COMPONENT (note that some components may not be mapped in the target workspace) for(IComponentHandle componentHandle : componentHandles) { //IMPORTANT from API desc: The order of the baselines in the result reflects the //order in which they were bases in the local history, // in reverse chronological order. List<IBaselineHandle> outgoingBaselineHandles = changeHistorySyncReport.outgoingBaselines(componentHandle); //IMPORTANT from API desc: The order of the change sets in the result reflects their // relative order in the local history for that component. List<IChangeSetHandle> outgoingChangeSetAfterBasisHandles = changeHistorySyncReport.outgoingChangeSetsAfterBasis(componentHandle); //DELIVER ONLY POSSIBILE LATEST BASELINE FOR COMPONENT AND CHANGESETS ON TOP if (outgoingBaselineHandles.size() > 0) { try { sourceWorkspaceConnection.deliver( targetWorkspaceConnection, changeHistorySyncReport, Collections.singletonList(outgoingBaselineHandles.get(0)), outgoingChangeSetAfterBasisHandles, progressMonitor); } catch (TeamRepositoryException e) { log.error("FAILED delivery last baseline and change sets",e); throw new SnipException("FAILED delivery last baseline and change sets",e); } } else { try { sourceWorkspaceConnection.deliver( targetWorkspaceConnection, changeHistorySyncReport, Collections.EMPTY_LIST, outgoingChangeSetAfterBasisHandles, progressMonitor); } catch (TeamRepositoryException e) { log.error("FAILED delivery change sets only",e); throw new SnipException("FAILED delivery change sets only",e); } } } |
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.