Skip to content

Commit

Permalink
[fixed JENKINS-19404] Removed id from debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgarnet committed Aug 29, 2013
1 parent d394e0e commit fe5e9c5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 43 deletions.
8 changes: 3 additions & 5 deletions src/main/java/net/praqma/hudson/notifier/CCUCMNotifier.java
Expand Up @@ -42,7 +42,6 @@ public class CCUCMNotifier extends Notifier {
private PrintStream out;

private Status status;
private String id = "";
private static Logger logger = Logger.getLogger( CCUCMNotifier.class.getName() );
private String jobName = "";
private Integer jobNumber = 0;
Expand Down Expand Up @@ -85,7 +84,6 @@ public boolean perform( AbstractBuild<?, ?> build, Launcher launcher, BuildListe
/* Prepare job variables */
jobName = build.getParent().getDisplayName().replace( ' ', '_' );
jobNumber = build.getNumber();
this.id = "[" + jobName + "::" + jobNumber + "]";

SCM scmTemp = build.getProject().getScm();
if( !( scmTemp instanceof CCUCMScm ) ) {
Expand Down Expand Up @@ -301,7 +299,7 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi

/* Remote post build step, common to all types */
try {
logger.fine( String.format( "%sRemote post build step", id ) );
logger.fine( String.format( "Remote post build step" ) );
out.println( String.format( "%s Performing common post build steps",logShortPrefix ) );
status = currentWorkspace.act( new RemotePostBuild( buildResult, status, listener, pstate.doMakeTag(), pstate.doRecommend(), pstate.getUnstable(), ( pstate.getPromotionLevel() == null ? true : false ), sourcebaseline, targetbaseline, sourcestream, targetstream, build.getParent().getDisplayName(), Integer.toString( build.getNumber() ) ) );
} catch( Exception e ) {
Expand All @@ -317,9 +315,9 @@ private void processBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildLi
if( status.getPromotedLevel() != null ) {
logger.fine("Baseline promotion level was changed on the remote: promotedLevel != null");
try {
logger.fine( String.format( "%sBaselines promotion planned to be set to %s", id, status.getPromotedLevel().toString() ) );
logger.fine( String.format( "Baselines promotion planned to be set to %s", status.getPromotedLevel().toString() ) );
pstate.getBaseline().setPromotionLevel( status.getPromotedLevel() );
logger.fine( String.format( "%sBaselines promotion level updates to %s", id, status.getPromotedLevel().toString() ) );
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() ) );
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/net/praqma/hudson/notifier/RemotePostBuild.java
Expand Up @@ -38,7 +38,6 @@ class RemotePostBuild implements FileCallable<Status> {
private boolean recommend = false;
private Status status;
private BuildListener listener;
private String id = "";
private PrintStream hudsonOut = null;
private Unstable unstable;

Expand All @@ -54,8 +53,6 @@ public RemotePostBuild( Result result, Status status, BuildListener listener,
this.displayName = displayName;
this.buildNumber = buildNumber;

this.id = "[" + displayName + "::" + buildNumber + "]";

this.sourcebaseline = sourcebaseline;
this.targetbaseline = targetbaseline;
this.sourcestream = sourcestream;
Expand Down Expand Up @@ -151,7 +148,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
status.setStable( false );
status.setRecommended( false );
hudsonOut.println( CCUCMNotifier.logShortPrefix +" Could not recommend Baseline " + targetbaseline.getShortname() + ": " + e.getMessage() );
logger.warning( id + "Could not recommend baseline: " + e.getMessage() );
logger.warning( "Could not recommend baseline: " + e.getMessage() );
}
}
} catch( Exception e ) {
Expand All @@ -163,14 +160,14 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
if( recommend ) {
status.setRecommended( false );
hudsonOut.println( CCUCMNotifier.logShortPrefix +" Could not promote baseline " + sourcebaseline.getShortname() + " and will not recommend " + targetbaseline.getShortname() + ". " + e.getMessage() );
logger.warning( id + "Could not promote baseline and will not recommend. " + e.getMessage() );
logger.warning( "Could not promote baseline and will not recommend. " + e.getMessage() );
} else {
/*
* As we will not recommend if we cannot promote, it's ok to
* break method here
*/
hudsonOut.println( CCUCMNotifier.logShortPrefix+" Could not promote baseline " + sourcebaseline.getShortname() + ". " + e.getMessage() );
logger.warning( id + "Could not promote baseline. " + e.getMessage() );
logger.warning( "Could not promote baseline. " + e.getMessage() );
}
}

Expand All @@ -190,7 +187,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
printPostedOutput( sourcebaseline );
noticeString = "*";
} else {
logger.warning( id + "Demoting baseline" );
logger.warning( "Demoting baseline" );
Project.PromotionLevel pl = sourcebaseline.demote();
status.setPromotedLevel( pl );
hudsonOut.println( CCUCMNotifier.logShortPrefix + " Baseline " + sourcebaseline.getShortname() + " is " + sourcebaseline.getPromotionLevel( true ).toString() + "." );
Expand All @@ -200,7 +197,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
// throw new NotifierException(
// "Could not demote baseline. " + e.getMessage() );
hudsonOut.println( CCUCMNotifier.logShortPrefix +" Could not demote baseline " + sourcebaseline.getShortname() + ". " + e.getMessage() );
logger.warning( id + "Could not demote baseline. " + e.getMessage() );
logger.warning( "Could not demote baseline. " + e.getMessage() );
}
} else {
status.setPromotedLevel( sourcebaseline.getPromotionLevel( false ) );
Expand Down Expand Up @@ -232,7 +229,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
}
}
} else {
logger.warning( id + "Tag object was null" );
logger.warning( "Tag object was null" );
hudsonOut.println( CCUCMNotifier.logShortPrefix + " Tag object was null, tag not set." );
}
}
Expand All @@ -248,7 +245,7 @@ public Status invoke( File workspace, VirtualChannel channel ) throws IOExceptio
throw new IOException( failBuild );
}

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

Expand Down
33 changes: 15 additions & 18 deletions src/main/java/net/praqma/hudson/remoting/CheckoutTask.java
Expand Up @@ -42,7 +42,6 @@ public class CheckoutTask implements FileCallable<EstablishResult> {
private Stream targetStream;
private BuildListener listener;
private Integer jobNumber;
private String id = "";

/**
* Determines whether to swipe the view or not.
Expand All @@ -67,8 +66,6 @@ public CheckoutTask( BuildListener listener, String jobname, Integer jobNumber,
this.any = any;

this.swipe = swipe;

this.id = "[" + jobname + "::" + jobNumber + "-cotask]";
}

@Override
Expand All @@ -78,7 +75,7 @@ public EstablishResult invoke( File workspace, VirtualChannel channel ) throws I

hudsonOut = listener.getLogger();

logger.fine( id + "Starting CheckoutTask" );
logger.fine( "Starting CheckoutTask" );

String diff = "";
String viewtag = makeViewtag();
Expand All @@ -97,19 +94,19 @@ public EstablishResult invoke( File workspace, VirtualChannel channel ) throws I
}

try {
logger.fine( id + "Getting dev stream" );
logger.fine( "Getting dev stream" );
Stream devstream = getDeveloperStream( "stream:" + viewtag, targetStream.getPVob() );
devstream.load();

logger.fine( id + "Getting foundation baseline" );
logger.fine( "Getting foundation baseline" );
Baseline foundation = devstream.getFoundationBaseline();
foundation.load();

if( !foundation.getStream().equals( targetStream ) ) {
hudsonOut.println( "[" + Config.nameShort + "] The foundation baseline " + foundation.getShortname() + " does not match the stream " + targetStream.getShortname() + ". Changelog will probably be bogus." );
}

logger.fine( id + "Making workspace" );
logger.fine( "Making workspace" );

makeWorkspace( workspace, viewtag );
List<Activity> bldiff = null;
Expand Down Expand Up @@ -137,7 +134,7 @@ public EstablishResult invoke( File workspace, VirtualChannel channel ) throws I
//int c = 0;
er.setActivities( bldiff );

logger.fine( id + "DONE" );
logger.fine( "DONE" );
//hudsonOut.println( c + " version" + ( c == 1 ? "" : "s" ) + " involved" );

logger.info( "CheckoutTask finished normally" );
Expand All @@ -163,23 +160,23 @@ private void makeWorkspace( File workspace, String viewtag ) throws ScmException
// We know we have a stream (st), because it is set in
// baselinesToBuild()
if( workspace != null ) {
logger.fine( id + "workspace: " + workspace.getAbsolutePath() );
logger.fine( "workspace: " + workspace.getAbsolutePath() );
} else {
logger.fine( id + "workspace must be null???" );
logger.fine( "workspace must be null???" );
}

File viewroot = new File( workspace, "view" );

logger.fine( id + "Creating dev strem" );
logger.fine( "Creating dev strem" );
Stream devstream = getDeveloperStream( "stream:" + viewtag, targetStream.getPVob() );

logger.fine( id + "Making view" );
logger.fine( "Making view" );
sv = Util.makeView( devstream, workspace, listener, loadModule, viewroot, viewtag, false );


// Now we have to rebase - if a rebase is in progress, the
// old one must be stopped and the new started instead
logger.fine( id + "Checking rebasing" );
logger.fine( "Checking rebasing" );
if( Rebase.isInProgress( devstream ) ) {
hudsonOut.print( "[" + Config.nameShort + "] Cancelling previous rebase." );
Rebase.cancelRebase( devstream );
Expand All @@ -190,12 +187,12 @@ private void makeWorkspace( File workspace, String viewtag ) throws ScmException
// to LAK
hudsonOut.print( "[" + Config.nameShort + "] Rebasing development stream (" + devstream.getShortname() + ") against parent stream (" + targetStream.getShortname() + ")" );
try {
logger.fine( id + "Rebasing" );
logger.fine( "Rebasing" );
Rebase rebase = new Rebase( devstream, sv, bl );
rebase.rebase( true );
logger.fine( id + "Rebasing done" );
logger.fine( "Rebasing done" );
} catch( RebaseException e1 ) {
logger.fine( id + "Rebasing failed: " + e1.getMessage() );
logger.fine( "Rebasing failed: " + e1.getMessage() );
hudsonOut.println( " Failed" );
throw e1;
}
Expand All @@ -204,10 +201,10 @@ private void makeWorkspace( File workspace, String viewtag ) throws ScmException

try {
hudsonOut.println("[" + Config.nameShort + "] Updating view using " + loadModule.toLowerCase() + " modules");
logger.fine( id + "Updating stream" );
logger.fine( "Updating stream" );
//sv.Update(true, true, true, false, Components.valueOf(loadModule.toUpperCase()), null);
sv.Update(swipe, true, true, false, new LoadRules( sv, Components.valueOf(loadModule.toUpperCase()) ));
logger.fine( id + "Updating done" );
logger.fine( "Updating done" );
} catch (ClearCaseException e) {
e.print( hudsonOut );
throw new ScmException("Could not update snapshot view", e );
Expand Down
Expand Up @@ -45,7 +45,6 @@ public class RemoteDeliver implements FileCallable<EstablishResult> {
private String baseline;
private String destinationstream;
private BuildListener listener;
private String id = "";
private SnapshotView snapview;

/*
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -71,7 +71,6 @@ public class CCUCMScm extends SCM {
private String buildProject;
private String jobName = "";
private Integer jobNumber;
private String id = "";

private boolean forceDeliver;

Expand Down Expand Up @@ -147,7 +146,6 @@ public boolean checkout( AbstractBuild<?, ?> build, Launcher launcher, FilePath

jobName = build.getParent().getDisplayName().replace( ' ', '_' );
jobNumber = build.getNumber();
this.id = "[" + jobName + "::" + jobNumber + "]";

PrintStream out = listener.getLogger();

Expand All @@ -158,7 +156,7 @@ public boolean checkout( AbstractBuild<?, ?> build, Launcher launcher, FilePath
out.println( "[" + Config.nameShort + "] Poll for posted deliveries: " + this.getMultisitePolling() );
out.println( "[" + Config.nameShort + "] Forcing deliver: " + forceDeliver );

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

/* Check for ClearCase on remote */
try {
Expand Down Expand Up @@ -346,7 +344,7 @@ private boolean initializeWorkspace( AbstractBuild<?, ?> build, FilePath workspa
fos.write( changelog.getBytes() );
fos.close();
} catch( IOException e ) {
logger.fine( id + "Could not write change log file" );
logger.fine( "Could not write change log file" );
consoleOutput.println( "[" + Config.nameShort + "] Could not write change log file" );
}

Expand Down Expand Up @@ -477,7 +475,7 @@ public boolean beginDeliver( AbstractBuild<?, ?> build, CCUCMBuildAction state,
fos.write( changelog.getBytes() );
fos.close();
} catch( IOException e ) {
logger.fine( id + "Could not write change log file" );
logger.fine( "Could not write change log file" );
consoleOutput.println( "[" + Config.nameShort + "] Could not write change log file" );
}

Expand Down Expand Up @@ -521,7 +519,7 @@ public boolean beginDeliver( AbstractBuild<?, ?> build, CCUCMBuildAction state,
logger.warning( ExceptionUtils.getFullStackTrace( e ) );
}
} else {
logger.fine( id + "No need for completing deliver" );
logger.fine( "No need for completing deliver" );
state.setNeedsToBeCompleted( false );
}

Expand Down Expand Up @@ -601,7 +599,6 @@ public PollingResult compareRemoteRevisionWith( AbstractProject<?, ?> project, L

jobName = project.getDisplayName().replace( ' ', '_' );
jobNumber = project.getNextBuildNumber();
this.id = "[" + jobName + "::" + jobNumber + "]";

PollingResult p = PollingResult.NO_CHANGES;

Expand Down Expand Up @@ -643,7 +640,10 @@ public PollingResult compareRemoteRevisionWith( AbstractProject<?, ?> project, L

List<Baseline> baselines = null;

/* We need to discriminate on promotion level, JENKINS-16620 */
/* We need to discriminate on promotion level, JENKINS-16620.
*
* This is ONLY for ANY!
* */
Date date = null;
if( plevel == null ) {
CCUCMBuildAction lastAction = getLastAction( project );
Expand Down Expand Up @@ -728,7 +728,7 @@ private List<Baseline> getBaselinesFromStreams( FilePath workspace, TaskListener
* @throws CCUCMException
*/
private List<Baseline> getValidBaselinesFromStream( FilePath workspace, Project.PromotionLevel plevel, Stream stream, Component component, Date date ) throws IOException, InterruptedException {
logger.fine( id + "Retrieving valid baselines." );
logger.fine( "Retrieving valid baselines." );

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

0 comments on commit fe5e9c5

Please sign in to comment.