continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r727964 - in /continuum/branches/continuum-distributed-builds: continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/ continuum-builder/src/main/java/org/apache/continuum/builder/utils/ continuum-builder/src/test/...
Date Fri, 19 Dec 2008 07:45:03 GMT
Author: ctan
Date: Thu Dec 18 23:45:02 2008
New Revision: 727964

URL: http://svn.apache.org/viewvc?rev=727964&view=rev
Log:
- fixed result data type for xmlrpc
- write buildoutput to file when returned from build agent
- fixed test

Modified:
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=727964&r1=727963&r2=727964&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
Thu Dec 18 23:45:02 2008
@@ -1,5 +1,9 @@
 package org.apache.continuum.builder.distributed.manager;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -20,6 +24,7 @@
 import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
 import org.apache.continuum.utils.ContinuumUtils;
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
@@ -355,12 +360,25 @@
 
             projectDao.updateProject( project );
 
-            //TODO: set state of next project to building
+            File buildOutputFile = configurationService.getBuildOutputFile( buildResult.getId(),
project.getId() );
+            
+            FileWriter fstream = new FileWriter( buildOutputFile );
+            BufferedWriter out = new BufferedWriter(fstream);
+            out.write( ContinuumBuildConstant.getBuildOutput( context ) == null ? "" : ContinuumBuildConstant.getBuildOutput(
context ) );
+            out.close();
         }
         catch ( ContinuumStoreException e )
         {
             throw new ContinuumException( "Error while updating build result for project",
e );
         }
+        catch ( ConfigurationException e )
+        {
+            throw new ContinuumException( "Error retrieving build output file", e );
+        }
+        catch ( IOException e )
+        {
+            throw new ContinuumException( "Error while writing build output to file", e );
+        }
     }
 
     public void prepareBuildFinished( Map context )

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java?rev=727964&r1=727963&r2=727964&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
Thu Dec 18 23:45:02 2008
@@ -82,12 +82,12 @@
 
     public static long getBuildStart( Map context )
     {
-        return getLong( context, KEY_BUILD_START );
+        return new Long( getString( context, KEY_BUILD_START ) );
     }
 
     public static long getBuildEnd( Map context )
     {
-        return getLong( context, KEY_BUILD_END );
+        return new Long( getString( context, KEY_BUILD_END ) );
     }
 
     public static int getBuildExitCode( Map context )

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java?rev=727964&r1=727963&r2=727964&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
Thu Dec 18 23:45:02 2008
@@ -89,12 +89,13 @@
         Map context = new HashMap();
         context.put( "project-id", project.getId() );
         context.put( "builddefinition-id", buildDef.getId() );
-        context.put( "build-start", expectedBuildResult.getStartTime() );
-        context.put( "build-end", expectedBuildResult.getEndTime() );
+        context.put( "build-start", new Long( expectedBuildResult.getStartTime() ).toString()
);
+        context.put( "build-end", new Long( expectedBuildResult.getEndTime() ).toString()
);
         context.put( "build-error", expectedBuildResult.getError() );
         context.put( "build-exit-code", expectedBuildResult.getExitCode() );
         context.put( "build-state", expectedBuildResult.getState() );
         context.put( "trigger", expectedBuildResult.getTrigger() );
+        context.put( "build-output", null );
         
         distributedBuildManager.updateBuildResult( context );
 

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=727964&r1=727963&r2=727964&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
Thu Dec 18 23:45:02 2008
@@ -91,11 +91,11 @@
             {
                 if ( buildResult.getStartTime() <= 0 )
                 {
-                    result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildContext.getBuildStartTime()
) );
+                    result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildContext.getBuildStartTime()
).toString() );
                 }
                 else
                 {
-                    result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildResult.getStartTime()
) );
+                    result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildResult.getStartTime()
).toString() );
                 }
 
                 if ( buildResult.getError() == null )
@@ -108,13 +108,13 @@
                 }
 
                 result.put( ContinuumBuildAgentUtil.KEY_BUILD_STATE, new Integer( buildResult.getState()
) );
-                result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( buildResult.getEndTime()
) );
+                result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( buildResult.getEndTime()
).toString() );
                 result.put( ContinuumBuildAgentUtil.KEY_BUILD_EXIT_CODE, buildResult.getExitCode()
);
             }
             else
             {
-                result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildContext.getBuildStartTime()
) );
-                result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( 0 ) );
+                result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildContext.getBuildStartTime()
).toString() );
+                result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( 0 ).toString()
);
                 result.put( ContinuumBuildAgentUtil.KEY_BUILD_STATE, new Integer( ContinuumProjectState.BUILDING
) );
                 result.put( ContinuumBuildAgentUtil.KEY_BUILD_ERROR, "" );
                 result.put( ContinuumBuildAgentUtil.KEY_BUILD_EXIT_CODE, new Integer( 0 )
);

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java?rev=727964&r1=727963&r2=727964&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m2/MavenTwoBuildExecutor.java
Thu Dec 18 23:45:02 2008
@@ -83,6 +83,7 @@
     
         arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( "
" );
     
+        /*
         Properties props = getContinuumSystemProperties( project );
         for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
         {
@@ -90,7 +91,8 @@
             String value = props.getProperty( name );
             arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append(
"\" " );
         }
-    
+        */
+
         arguments.append( StringUtils.clean( buildDefinition.getGoals() ) );
 
         return executeShellCommand( project, executable, arguments.toString(), buildOutput,
null );

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java?rev=727964&r1=727963&r2=727964&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java
Thu Dec 18 23:45:02 2008
@@ -12,6 +12,7 @@
 import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
 import org.apache.continuum.buildagent.manager.BuildAgentManager;
 import org.apache.continuum.buildagent.utils.BuildContextToBuildDefinition;
+import org.apache.continuum.buildagent.utils.BuildContextToProject;
 import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil;
 import org.apache.continuum.taskqueue.BuildProjectTask;
 import org.apache.maven.continuum.ContinuumException;
@@ -93,6 +94,13 @@
 
     private void initializeBuildContext( BuildContext buildContext )
     {
+        Map<String, Object> actionContext = buildContext.getActionContext();
+
+        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT_ID, buildContext.getProjectId()
);
+        actionContext.put( ContinuumBuildAgentUtil.KEY_PROJECT, BuildContextToProject.getProject(
buildContext ) );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION, BuildContextToBuildDefinition.getBuildDefinition(
buildContext ) );
+        actionContext.put( ContinuumBuildAgentUtil.KEY_TRIGGER, buildContext.getTrigger()
);
+
         buildContext.setBuildStartTime( System.currentTimeMillis() );
     }
     
@@ -122,6 +130,7 @@
     }
 
     private void endBuild( BuildContext buildContext )
+        throws TaskExecutionException
     {
         // return build result to master
         BuildResult buildResult = buildContext.getBuildResult();
@@ -131,8 +140,8 @@
         result.put( ContinuumBuildAgentUtil.KEY_BUILD_DEFINITION_ID, new Integer( buildContext.getBuildDefinitionId()
) );
         result.put( ContinuumBuildAgentUtil.KEY_TRIGGER, new Integer( buildContext.getTrigger()
) );
         result.put( ContinuumBuildAgentUtil.KEY_BUILD_STATE, new Integer( buildResult.getState()
) );
-        result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildResult.getStartTime()
) );
-        result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( buildResult.getEndTime()
) );
+        result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildResult.getStartTime()
).toString() );
+        result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( buildResult.getEndTime()
).toString() );
         result.put( ContinuumBuildAgentUtil.KEY_BUILD_EXIT_CODE, new Integer( buildResult.getExitCode()
) );
         
         String buildOutput = getBuildOutputText( buildContext.getProjectId() );
@@ -153,6 +162,16 @@
         {
             result.put( ContinuumBuildAgentUtil.KEY_BUILD_ERROR, "" );
         }
+
+        try
+        {
+            buildAgentManager.returnBuildResult( result );
+        }
+        catch ( ContinuumException e )
+        {
+            log.error( "Failed to return build result for project '" + buildContext.getProjectName()
+ "'", e );
+            throw new TaskExecutionException( "Failed to return build result for project
'" + buildContext.getProjectName() + "'", e );
+        }
     }
 
     private void performAction( String actionName, BuildContext context )



Mime
View raw message