JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
getLogger().debug( "Creating Snapshot..." );
StreamConsumer tagConsumer =
new DebugLoggerConsumer( getLogger() ); // No need for a dedicated consumer for this
ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
JazzScmCommand tagCreateSnapshotCmd =
createTagCreateSnapshotCommand( jazzRepo, fileSet, tag, scmTagParameters );
int status = tagCreateSnapshotCmd.execute( tagConsumer, errConsumer );
if ( status != 0 || errConsumer.hasBeenFed() )
{
return new TagScmResult( tagCreateSnapshotCmd.getCommandString(),
"Error code for Jazz SCM tag (SNAPSHOT) command - " + status,
errConsumer.getOutput(), false );
}
// ------------------------------------------------------------------
// We create the workspace based on the tag here, as the scm tool
// can not currently check directly out from a snapshot (only a workspace).
getLogger().debug( "Creating Workspace from Snapshot..." );
JazzScmCommand tagCreateWorkspaceCmd = createTagCreateWorkspaceCommand( jazzRepo, fileSet, tag );
errConsumer = new ErrorConsumer( getLogger() );
status = tagCreateWorkspaceCmd.execute( tagConsumer, errConsumer );
if ( status != 0 || errConsumer.hasBeenFed() )
{
return new TagScmResult( tagCreateWorkspaceCmd.getCommandString(),
"Error code for Jazz SCM tag (WORKSPACE) command - " + status,
errConsumer.getOutput(), false );
}
// ------------------------------------------------------------------
if ( jazzRepo.isPushChangesAndHaveFlowTargets() )
{
// isPushChanges = true, and we have something to deliver and promote to.
getLogger().debug( "Promoting and delivering..." );
// So we deliver the code to the target stream (or workspace)
getLogger().debug( "Delivering..." );
JazzScmCommand tagDeliverCommand = createTagDeliverCommand( jazzRepo, fileSet, tag );
errConsumer = new ErrorConsumer( getLogger() );
status = tagDeliverCommand.execute( tagConsumer, errConsumer );
if ( status != 0 || errConsumer.hasBeenFed() )
{
return new TagScmResult( tagDeliverCommand.getCommandString(),
"Error code for Jazz SCM deliver command - " + status, errConsumer.getOutput(),
false );
}
// And now we promote the snapshot to the target stream (or workspace)
getLogger().debug( "Promoting snapshot..." );
JazzScmCommand tagSnapshotPromoteCommand = createTagSnapshotPromoteCommand( jazzRepo, fileSet, tag );
errConsumer = new ErrorConsumer( getLogger() );
status = tagSnapshotPromoteCommand.execute( tagConsumer, errConsumer );
if ( status != 0 || errConsumer.hasBeenFed() )
{
return new TagScmResult( tagSnapshotPromoteCommand.getCommandString(),
"Error code for Jazz SCM snapshot promote command - " + status,
errConsumer.getOutput(), false );
}
}
// We don't have a JazzTagConsumer so just build up all the files...
List<ScmFile> taggedFiles = new ArrayList<ScmFile>( fileSet.getFileList().size() );