Skip to content

Commit

Permalink
[fixed JENKINS-19644] Fixing serilization problem
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgarnet committed Sep 18, 2013
1 parent 957cfe2 commit 13630f5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 42 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.21</version>
<version>0.6.22-SNAPSHOT</version>
<type>jar</type>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>cool</artifactId>
<version>0.6.21</version>
<version>0.6.22-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Expand Down
Expand Up @@ -43,10 +43,14 @@ public GetChanges( BuildListener listener, Stream destinationStream, Baseline ba
public List<Activity> invoke( File workspace, VirtualChannel channel ) throws IOException, InterruptedException {

logger = Logger.getLogger( GetChanges.class.getName() );
logger.fine( "Get changeset " );
logger.fine( "Get changeset" );

try {
return Version.getBaselineDiff( destinationStream, baseline, true, new File( viewPath ) );
List<Activity> activities = Version.getBaselineDiff( destinationStream, baseline, true, new File( viewPath ) );
for( Activity activity : activities ) {
activity.load();
}
return activities;
} catch( Exception e ) {
throw new IOException( "Error while retrieving changes", e );
}
Expand Down
68 changes: 32 additions & 36 deletions src/main/java/net/praqma/hudson/scm/CCUCMScm.java
Expand Up @@ -442,46 +442,42 @@ private void resolveBaseline( FilePath workspace, AbstractProject<?, ?> project,
out.println( "" );
}

public boolean beginDeliver( AbstractBuild<?, ?> build, CCUCMBuildAction state, BuildListener listener, File changelogFile ) {
public boolean beginDeliver( AbstractBuild<?, ?> build, CCUCMBuildAction state, BuildListener listener, File changelogFile ) throws IOException, InterruptedException {
FilePath workspace = build.getWorkspace();
PrintStream consoleOutput = listener.getLogger();
boolean result = true;

try {
logger.config( "Starting remote deliver" );

CCUCMBuildAction action = build.getAction( CCUCMBuildAction.class );

/* Create the deliver view */
logger.fine( "Creating deliver view" );
MakeDeliverView mdv = new MakeDeliverView( listener, build.getParent().getDisplayName(), loadModule, state.getStream() );
SnapshotView view = workspace.act( mdv );
action.setViewPath( view.getViewRoot() );
action.setViewTag( view.getViewtag() );
this.viewtag = view.getViewtag();

/* Get changes */
logger.fine( "Getting changes" );
GetChanges gc = new GetChanges( listener, state.getStream(), state.getBaseline(), view.getPath() );
List<Activity> activities = workspace.act( gc );

/* ... And create the changelog */
String changelog = "";
changelog = Util.createChangelog( activities, action.getBaseline(), trimmedChangeSet );
//logger.fine( changelog );
action.setActivities( activities );

/* Write change log */
try {
FileOutputStream fos = new FileOutputStream( changelogFile );
fos.write( changelog.getBytes() );
fos.close();
} catch( IOException e ) {
logger.fine( "Could not write change log file" );
consoleOutput.println( "[" + Config.nameShort + "] Could not write change log file" );
}
logger.config( "Starting remote deliver" );
CCUCMBuildAction action = build.getAction( CCUCMBuildAction.class );

logger.fine( "Creating deliver view" );
MakeDeliverView mdv = new MakeDeliverView( listener, build.getParent().getDisplayName(), loadModule, state.getStream() );
SnapshotView view = workspace.act( mdv );
action.setViewPath( view.getViewRoot() );
action.setViewTag( view.getViewtag() );
this.viewtag = view.getViewtag();

logger.fine( "Getting changes" );
GetChanges gc = new GetChanges( listener, state.getStream(), state.getBaseline(), view.getPath() );
List<Activity> activities = workspace.act( gc );

/* Starting deliver */
/* ... And create the changelog */
String changelog = "";
changelog = Util.createChangelog( activities, action.getBaseline(), trimmedChangeSet );
//logger.fine( changelog );
action.setActivities( activities );

/* Write change log */
try {
FileOutputStream fos = new FileOutputStream( changelogFile );
fos.write( changelog.getBytes() );
fos.close();
} catch( IOException e ) {
logger.fine( "Could not write change log file" );
consoleOutput.println( "[" + Config.nameShort + "] Could not write change log file" );
}

try {
logger.fine( "Starting deliver" );
StartDeliver sd = new StartDeliver( listener, state.getStream(), state.getBaseline(), view, loadModule, state.doForceDeliver(), state.doRemoveViewPrivateFiles() );
workspace.act( sd );
Expand Down Expand Up @@ -569,7 +565,7 @@ public void buildEnvVars( AbstractBuild<?, ?> build, Map<String, String> env ) {
String CC_BASELINE = "";
String CC_VIEWPATH = "";
String CC_VIEWTAG = "";

try {

CCUCMBuildAction action = build.getAction( CCUCMBuildAction.class );
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/net/praqma/hudson/scm/Environment.java
@@ -0,0 +1,23 @@
package net.praqma.hudson.scm;

import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.tasks.BuildWrapper;

import java.io.IOException;

/**
* @author cwolfgang
*/
@Extension
public class Environment extends BuildWrapper {
/*
@Override
public Environment setUp( AbstractBuild build, Launcher launcher, BuildListener listener ) throws IOException, InterruptedException {
listener.getLogger().println("AH YEAH!");
Environment env = new Envi
}
*/
}
3 changes: 3 additions & 0 deletions src/test/java/net/praqma/hudson/test/SystemValidator.java
Expand Up @@ -347,7 +347,10 @@ private void doCheckChangeset() {
System.out.println( "[assert] The number of changesets must be " + numberOfChanges );

try {
System.out.println( "CHANGE LOG: " + build.getChangeSet() );
System.out.println( "CHANGE LOG: " + build.getChangeSet().getClass() );
ChangeLogSetImpl cls = (ChangeLogSetImpl) build.getChangeSet();

assertThat( cls.getEntries().size(), is( numberOfChanges ) );
} catch( ClassCastException e ) {
if( numberOfChanges > 0 ) {
Expand Down
Expand Up @@ -36,15 +36,23 @@ public void jenkins19558() throws Exception {
CCUCMBuildAction action1 = build1.getAction( CCUCMBuildAction.class );
action1.getViewPath();


Stream target = ccenv.context.streams.get( "one_int" );
Stream source = ccenv.context.streams.get( "one_dev" );

System.out.println( "SOURCE: " + source );
System.out.println( "TARGET: " + target );
System.out.println( "PATH: " + action1.getViewPath() );
System.out.println( "TAG: " + action1.getViewTag() );
Deliver deliver = new Deliver( source, target, action1.getViewPath(), action1.getViewTag() );
deliver.deliver( true, false, false, false );
boolean b = deliver.deliver( true, false, false, false );
System.out.println( "DELIVER: " + b );


AbstractBuild build2 = jenkins.getProjectBuilder( project ).build();

System.out.println( "1CHANGE LOG: " + build2.getChangeSet() );
System.out.println( "1CHANGE LOG: " + build2.getChangeSet().getClass() );

new SystemValidator( build2 ).
validateBuild( Result.FAILURE ).
checkChangeset( 1 ).
Expand Down

0 comments on commit 13630f5

Please sign in to comment.