Skip to content

Commit

Permalink
[JENKINS-13944] Throwing exception when no tag type exists
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgarnet committed Jul 15, 2012
1 parent e38056c commit 0aa861d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -214,14 +214,14 @@
<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.0</version>
<version>0.6.1-SNAPSHOT</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.0</version>
<version>0.6.1-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/praqma/hudson/Util.java
Expand Up @@ -25,6 +25,7 @@
import net.praqma.clearcase.ucm.entities.Stream;
import net.praqma.clearcase.ucm.entities.Version;
import net.praqma.clearcase.ucm.utils.BuildNumber;
import net.praqma.clearcase.ucm.utils.VersionList;
import net.praqma.clearcase.ucm.view.SnapshotView;
import net.praqma.clearcase.ucm.view.SnapshotView.LoadRules;
import net.praqma.clearcase.ucm.view.UCMView;
Expand Down Expand Up @@ -78,7 +79,8 @@ public static String createChangelog( List<Activity> changes, Baseline bl ) {
buffer.append( "<activity>" );
buffer.append( ( "<actName>" + act.getShortname() + "</actName>" ) );
buffer.append( ( "<author>" + act.getUser() + "</author>" ) );
List<Version> versions = act.changeset.versions;
//List<Version> versions = act.changeset.versions;
VersionList versions = new VersionList( act.changeset.versions ).getLatest();
String temp = null;
for( Version v : versions ) {
try {
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/praqma/hudson/notifier/CCUCMNotifier.java
Expand Up @@ -434,7 +434,10 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
status.setStable( false );
logger.debug( id + "Something went wrong: " + e.getMessage(), id );
logger.warning( e, id );
out.println( "[" + Config.nameShort + "] Error: Post build failed: " + e.getMessage() );
out.println( "[" + Config.nameShort + "] Error: Post build failed" );
Throwable cause = net.praqma.util.ExceptionUtils.unpackFrom( IOException.class, e );

ExceptionUtils.print( cause, out, true );
}

/* If the promotion level of the baseline was changed on the remote */
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/net/praqma/hudson/notifier/RemotePostBuild.java
Expand Up @@ -12,6 +12,8 @@
import java.util.Set;

import net.praqma.clearcase.exceptions.ClearCaseException;
import net.praqma.clearcase.exceptions.TagException;
import net.praqma.clearcase.exceptions.TagException.Type;
import net.praqma.clearcase.ucm.entities.Baseline;
import net.praqma.clearcase.ucm.entities.Project;
import net.praqma.clearcase.ucm.entities.Stream;
Expand Down Expand Up @@ -112,9 +114,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
tag = sourcebaseline.getTag( this.displayName, this.buildNumber );
status.setTagAvailable( true );
} catch( Exception e ) {
//e.printStackTrace( hudsonOut );
ExceptionUtils.print( e, hudsonOut, false );
ExceptionUtils.log( e, true );
hudsonOut.println( "Unable to get tag for " + sourcebaseline.getNormalizedName() );
}
}

Expand Down Expand Up @@ -214,6 +214,8 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio

}

Exception failBuild = null;

/* Persist the Tag */
if( makeTag ) {
if( tag != null ) {
Expand All @@ -226,9 +228,14 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
}
} catch( Exception e ) {
hudsonOut.println( "[" + Config.nameShort + "] Could not change tag in ClearCase. Contact ClearCase administrator to do this manually." );
e.printStackTrace( hudsonOut );
ExceptionUtils.print( e, hudsonOut, false );
ExceptionUtils.log( e, true );
if( e instanceof TagException && ((TagException) e).getType().equals( Type.NO_SUCH_HYPERLINK ) ) {
logger.error( "Hyperlink type not found, failing build" );
hudsonOut.println( "Hyperlink type not found, failing build" );
failBuild = e;
} else {
ExceptionUtils.print( e, hudsonOut, false );
ExceptionUtils.log( e, true );
}
}
} else {
logger.warning( id + "Tag object was null" );
Expand All @@ -242,9 +249,14 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
} else {
status.setBuildDescr( setDisplaystatus( sourcebaseline.getShortname(), newPLevel + noticeString, targetbaseline.getShortname(), status.getErrorMessage() ) );
}

logger.info( id + "Remote post build finished normally" );

Logger.removeAppender( app );

if( failBuild != null ) {
throw new IOException( failBuild );
}

logger.info( id + "Remote post build finished normally" );
return status;
}

Expand Down
8 changes: 7 additions & 1 deletion src/test/java/net/praqma/hudson/test/SystemValidator.java
Expand Up @@ -168,7 +168,13 @@ public void checkBaselineTag() {
try {
System.out.println( "[assert] " + taggedBaseline.getNormalizedName() + " must " + (baselineMustBeTagged?" ":"not ") + "be tagged" );
tag = Tag.getTag( taggedBaseline, build.getParent().getDisplayName(), build.getNumber()+"", false );
assertNotNull( tag );
if( baselineMustBeTagged ) {
assertNotNull( tag );

/* TODO validate cgi string */
} else {
assertNull( tag );
}
} catch( Exception e ) {
fail( "Checking tag failed: " + e.getMessage() );
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ public void story11() throws Exception {
/* First build to create a view */
AbstractBuild<?, ?> build = jenkins.initiateBuild( ccenv.getUniqueName(), "self", "_System@" + ccenv.getPVob(), "one_int@" + ccenv.getPVob(), false, true, false, false, false, false );
Baseline baseline = ccenv.context.baselines.get( "model-1" );
new SystemValidator( build ).validateBuild( Result.FAILURE ).validateBaselineTag( baseline, false ).validate();
new SystemValidator( build ).validateBuild( Result.UNSTABLE ).validateBaselineTag( baseline, false ).validate();
}


Expand Down

0 comments on commit 0aa861d

Please sign in to comment.