Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-19404] Removed unused code, changed to reject baseline
  • Loading branch information
wolfgarnet committed Aug 30, 2013
1 parent fe5e9c5 commit 08921e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 46 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -445,14 +445,14 @@
<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.20</version>
<version>0.6.21-SNAPSHOT</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.20</version>
<version>0.6.21-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/net/praqma/hudson/notifier/CCUCMNotifier.java
Expand Up @@ -313,18 +313,10 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi

/* If the promotion level of the baseline was changed on the remote */
if( status.getPromotedLevel() != null ) {
logger.fine("Baseline promotion level was changed on the remote: promotedLevel != null");
try {
logger.fine( String.format( "Baselines promotion planned to be set to %s", status.getPromotedLevel().toString() ) );
pstate.getBaseline().setPromotionLevel( status.getPromotedLevel() );
logger.fine( String.format( "Baselines promotion level updates to %s", status.getPromotedLevel().toString() ) );
} catch( UnableToPromoteBaselineException e ) {
logger.warning( "===UnableToPromoteBaseline===" );
logger.warning( String.format( "Unable to set promotion level of baseline %s to %s",e.getEntity() != null ? e.getEntity().getFullyQualifiedName() : "null", e.getPromotionLevel() ) );
e.print( out );
logger.warning( "===UnableToPromoteBaseline===" );
}
logger.fine("Baseline promotion level was remotely changed, " + status.getPromotedLevel() );
pstate.getBaseline().setLocalPromotionLevel( status.getPromotedLevel() );
}

logger.fine("Setting build status on Status object");
status.setBuildStatus( buildResult );

Expand Down
15 changes: 7 additions & 8 deletions src/main/java/net/praqma/hudson/notifier/RemotePostBuild.java
Expand Up @@ -7,6 +7,7 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.praqma.clearcase.exceptions.ClearCaseException;
import net.praqma.clearcase.exceptions.TagException;
Expand Down Expand Up @@ -121,7 +122,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
Project.PromotionLevel pl;
if( !status.isStable() && !unstable.treatSuccessful() ) {
/* Treat the not stable build as unsuccessful */
pl = sourcebaseline.demote();
pl = sourcebaseline.reject();
hudsonOut.println( CCUCMNotifier.logShortPrefix + " Baseline " + sourcebaseline.getShortname() + " is " + pl.toString() + "." );
} else {
/* Treat the build as successful */
Expand Down Expand Up @@ -180,24 +181,22 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
tag.setEntry( "buildstatus", "FAILURE" );
}

/* Demote baseline, not any */
/* Reject baseline, not any */
if( !any ) {
try {
if( hasRemoteMastership() ) {
printPostedOutput( sourcebaseline );
noticeString = "*";
} else {
logger.warning( "Demoting baseline" );
Project.PromotionLevel pl = sourcebaseline.demote();
logger.warning( "Rejecting baseline" );
Project.PromotionLevel pl = sourcebaseline.reject();
status.setPromotedLevel( pl );
hudsonOut.println( CCUCMNotifier.logShortPrefix + " Baseline " + sourcebaseline.getShortname() + " is " + sourcebaseline.getPromotionLevel( true ).toString() + "." );
}
} catch( Exception e ) {
status.setStable( false );
// throw new NotifierException(
// "Could not demote baseline. " + e.getMessage() );
hudsonOut.println( CCUCMNotifier.logShortPrefix +" Could not demote baseline " + sourcebaseline.getShortname() + ". " + e.getMessage() );
logger.warning( "Could not demote baseline. " + e.getMessage() );
hudsonOut.println( CCUCMNotifier.logShortPrefix +" Could not reject baseline " + sourcebaseline.getShortname() );
logger.log( Level.WARNING, "Could not reject baseline", e );
}
} else {
status.setPromotedLevel( sourcebaseline.getPromotionLevel( false ) );
Expand Down
28 changes: 3 additions & 25 deletions src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -154,7 +154,6 @@ public boolean checkout( AbstractBuild<?, ?> build, Launcher launcher, FilePath
out.println( "[" + Config.nameShort + "] ClearCase UCM Plugin version " + version );
out.println( "[" + Config.nameShort + "] Allow for slave polling: " + this.getSlavePolling() );
out.println( "[" + Config.nameShort + "] Poll for posted deliveries: " + this.getMultisitePolling() );
out.println( "[" + Config.nameShort + "] Forcing deliver: " + forceDeliver );

logger.info( "ClearCase UCM plugin v. " + version );

Expand Down Expand Up @@ -420,7 +419,7 @@ private void resolveBaseline( FilePath workspace, AbstractProject<?, ?> project,
}
}

/* Find the Baselines and store them */
/* Find the Baselines and store them, none of the methods returns null! At least an empty list */
/* Old skool self polling */
if( polling.isPollingSelf() ) {
baselines = getValidBaselinesFromStream( workspace, plevel, action.getStream(), action.getComponent(), date );
Expand All @@ -436,10 +435,6 @@ private void resolveBaseline( FilePath workspace, AbstractProject<?, ?> project,
//action.setBaselines( baselines );
action.setBaseline( selectBaseline( baselines, plevel ) );

if( baselines == null || baselines.size() < 1 ) {
throw new CCUCMException( "Unable to get Baselines" );
}

/* Print the baselines to jenkins out */
printBaselines( baselines, out );
out.println( "" );
Expand Down Expand Up @@ -671,12 +666,7 @@ public PollingResult compareRemoteRevisionWith( AbstractProject<?, ?> project, L

/**
* Get the {@link Baseline}s from a {@link Stream}s related Streams.
* @param workspace
* @param listener
* @param consoleOutput
* @param stream
* @param component
* @param pollingChildStreams
*
* @return A list of {@link Baseline}'s
*/
private List<Baseline> getBaselinesFromStreams( FilePath workspace, TaskListener listener, PrintStream consoleOutput, Stream stream, Component component, boolean pollingChildStreams, Date date ) {
Expand Down Expand Up @@ -729,19 +719,7 @@ private List<Baseline> getBaselinesFromStreams( FilePath workspace, TaskListener
*/
private List<Baseline> getValidBaselinesFromStream( FilePath workspace, Project.PromotionLevel plevel, Stream stream, Component component, Date date ) throws IOException, InterruptedException {
logger.fine( "Retrieving valid baselines." );

/* The baseline list */
List<Baseline> baselines = new ArrayList<Baseline>();

/**
* When polling for self. (The other polling options uses different RemoteUtil methods) Passing in 'true' for multisite polling is not a good idea! Set this to false.
*
* TODO:Needs to be reviewed by chw and les. Remove upon release.
*/

baselines = RemoteUtil.getRemoteBaselinesFromStream( workspace, component, stream, plevel, this.getSlavePolling(), this.getMultisitePolling(), date );

return baselines;
return RemoteUtil.getRemoteBaselinesFromStream( workspace, component, stream, plevel, this.getSlavePolling(), this.getMultisitePolling(), date );
}

/**
Expand Down

0 comments on commit 08921e4

Please sign in to comment.