Skip to content

Commit

Permalink
[JENKINS-19558] Trying out new method in SCM
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgarnet committed Sep 26, 2013
1 parent 5b52c33 commit 0a87206
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 53 deletions.
105 changes: 54 additions & 51 deletions src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -273,76 +273,79 @@ public boolean checkout( AbstractBuild<?, ?> build, Launcher launcher, FilePath

@Override
public void postCheckout( AbstractBuild<?, ?> build, Launcher launcher, FilePath workspace, BuildListener listener ) throws IOException, InterruptedException {
listener.getLogger().println("WHOOOOP! Writing from post checkout: " + workspace);

CCUCMBuildAction state = build.getAction( CCUCMBuildAction.class );
/* This is really only interesting if child or sibling polling */
if( polling.isPollingOther() ) {

PrintStream consoleOutput = listener.getLogger();
CCUCMBuildAction state = build.getAction( CCUCMBuildAction.class );

try {
logger.fine( "Starting deliver" );
StartDeliver sd = new StartDeliver( listener, state.getStream(), state.getBaseline(), state.getSnapshotView(), loadModule, state.doForceDeliver(), state.doRemoveViewPrivateFiles() );
workspace.act( sd );
PrintStream consoleOutput = listener.getLogger();

consoleOutput.println( "[" + Config.nameShort + "] Deliver successful" );
try {
logger.fine( "Starting deliver" );
StartDeliver sd = new StartDeliver( listener, state.getStream(), state.getBaseline(), state.getSnapshotView(), loadModule, state.doForceDeliver(), state.doRemoveViewPrivateFiles() );
workspace.act( sd );

/* Deliver failed */
} catch( Exception e ) {
consoleOutput.println( "[" + Config.nameShort + "] Deliver failed" );
consoleOutput.println( "[" + Config.nameShort + "] Deliver successful" );

/* Check for exception types */
Exception cause = (Exception) net.praqma.util.ExceptionUtils.unpackFrom( IOException.class, e );
/* Deliver failed */
} catch( Exception e ) {
consoleOutput.println( "[" + Config.nameShort + "] Deliver failed" );

consoleOutput.println( "[" + Config.nameShort + "] Cause: " + cause.getClass() );
/* Check for exception types */
Exception cause = (Exception) net.praqma.util.ExceptionUtils.unpackFrom( IOException.class, e );

/* Re-throw */
try {
logger.log( Level.WARNING, "", cause );
throw cause;
} catch( DeliverException de ) {
consoleOutput.println( "[" + Config.nameShort + "] Cause: " + cause.getClass() );

/* Re-throw */
try {
logger.log( Level.WARNING, "", cause );
throw cause;
} catch( DeliverException de ) {

consoleOutput.println( "[" + Config.nameShort + "] " + de.getType() );

consoleOutput.println( "[" + Config.nameShort + "] " + de.getType() );
/* We need to store this information anyway */
state.setViewPath( de.getDeliver().getViewContext() );
state.setViewTag( de.getDeliver().getViewtag() );

/* We need to store this information anyway */
state.setViewPath( de.getDeliver().getViewContext() );
state.setViewTag( de.getDeliver().getViewtag() );
/* The deliver is started, cancel it */
if( de.isStarted() ) {
try {
consoleOutput.print( "[" + Config.nameShort + "] Cancelling deliver. " );
RemoteUtil.completeRemoteDeliver( workspace, listener, state.getBaseline(), state.getStream(), de.getDeliver().getViewtag(), de.getDeliver().getViewContext(), false );
consoleOutput.println( "Success" );

/* The deliver is started, cancel it */
if( de.isStarted() ) {
try {
consoleOutput.print( "[" + Config.nameShort + "] Cancelling deliver. " );
RemoteUtil.completeRemoteDeliver( workspace, listener, state.getBaseline(), state.getStream(), de.getDeliver().getViewtag(), de.getDeliver().getViewContext(), false );
consoleOutput.println( "Success" );
/* Make sure, that the post step is not run */
state.setNeedsToBeCompleted( false );

/* Make sure, that the post step is not run */
} catch( Exception ex ) {
consoleOutput.println( "[" + Config.nameShort + "] Failed to cancel deliver" );
consoleOutput.println( ExceptionUtils.getFullStackTrace( e ) );
logger.warning( ExceptionUtils.getFullStackTrace( e ) );
}
} else {
logger.fine( "No need for completing deliver" );
state.setNeedsToBeCompleted( false );
}

} catch( Exception ex ) {
consoleOutput.println( "[" + Config.nameShort + "] Failed to cancel deliver" );
consoleOutput.println( ExceptionUtils.getFullStackTrace( e ) );
logger.warning( ExceptionUtils.getFullStackTrace( e ) );
/* Write something useful to the output */
if( de.getType().equals( Type.MERGE_ERROR ) ) {
consoleOutput.println( "[" + Config.nameShort + "] Changes need to be manually merged, The stream " + state.getBaseline().getStream().getShortname() + " must be rebased to the most recent baseline on " + state.getStream().getShortname() + " - During the rebase the merge conflict should be solved manually. Hereafter create a new baseline on " + state.getBaseline().getStream().getShortname() + "." );
state.setError( "merge error" );
}
} else {
logger.fine( "No need for completing deliver" );
state.setNeedsToBeCompleted( false );
}

/* Write something useful to the output */
if( de.getType().equals( Type.MERGE_ERROR ) ) {
consoleOutput.println( "[" + Config.nameShort + "] Changes need to be manually merged, The stream " + state.getBaseline().getStream().getShortname() + " must be rebased to the most recent baseline on " + state.getStream().getShortname() + " - During the rebase the merge conflict should be solved manually. Hereafter create a new baseline on " + state.getBaseline().getStream().getShortname() + "." );
state.setError( "merge error" );
/* Force deliver not cancelled */
} catch( DeliverNotCancelledException e1 ) {
consoleOutput.println( "[" + Config.nameShort + "] Failed to force cancel existing deliver" );
state.setNeedsToBeCompleted( false );
} catch( Exception e1 ) {
logger.log( Level.WARNING, "", e );
e.printStackTrace( consoleOutput );
}

/* Force deliver not cancelled */
} catch( DeliverNotCancelledException e1 ) {
consoleOutput.println( "[" + Config.nameShort + "] Failed to force cancel existing deliver" );
state.setNeedsToBeCompleted( false );
} catch( Exception e1 ) {
logger.log( Level.WARNING, "", e );
e.printStackTrace( consoleOutput );
throw new AbortException( "Unable to start deliver" );
}

throw new AbortException( "Unable to start deliver" );
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/praqma/hudson/scm/Polling.java
Expand Up @@ -56,7 +56,10 @@ public boolean isPollingSelf() {
return false;
}
}


/**
* Returns true if {@link Polling} other {@link net.praqma.clearcase.ucm.entities.Stream}'s
*/
public boolean isPollingOther() {
if( this.type.equals(PollingType.childs) || this.type.equals( PollingType.siblings ) ) {
return true;
Expand Down
Expand Up @@ -55,7 +55,7 @@ public void jenkins19558() throws Exception {

new SystemValidator( build2 ).
validateBuild( Result.FAILURE ).
checkChangeset( 1 ).
checkChangeset( 2 ).
validate();
}

Expand Down

0 comments on commit 0a87206

Please sign in to comment.