You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ba...@apache.org on 2013/06/09 00:09:30 UTC

svn commit: r1491081 - /continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java

Author: batkinson
Date: Sat Jun  8 22:09:30 2013
New Revision: 1491081

URL: http://svn.apache.org/r1491081
Log:
[CONTINUUM-2705] Can't build projects with null builddef fields

Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java?rev=1491081&r1=1491080&r2=1491081&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java Sat Jun  8 22:09:30 2013
@@ -19,6 +19,16 @@ package org.apache.continuum.buildmanage
  * under the License.
  */
 
+import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+
 import org.apache.continuum.buildqueue.BuildQueueService;
 import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.dao.BuildDefinitionDao;
@@ -50,15 +60,6 @@ import org.codehaus.plexus.util.StringUt
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.annotation.Resource;
-
 /**
  * Parallel builds manager.
  *
@@ -164,7 +165,7 @@ public class ParallelBuildsManager
                                BuildTrigger buildTrigger, Map<Integer, ScmResult> scmResultMap, int projectGroupId )
         throws BuildManagerException
     {
-        int firstProjectId = 0;
+        Project firstBuildableProject = null;
         // get id of the first project in the list that is not yet in the build queue
         for ( Project project : projects )
         {
@@ -172,7 +173,7 @@ public class ParallelBuildsManager
             {
                 if ( !isInQueue( project.getId(), BUILD_QUEUE, -1 ) && !isProjectInAnyCurrentBuild( project.getId() ) )
                 {
-                    firstProjectId = project.getId();
+                    firstBuildableProject = project;
                     break;
                 }
             }
@@ -182,17 +183,18 @@ public class ParallelBuildsManager
             }
         }
 
-        if ( firstProjectId != 0 )
+        boolean projectsToBuild = firstBuildableProject != null;
+
+        if ( projectsToBuild )
         {
-            BuildDefinition buildDef = projectsBuildDefinitionsMap.get( firstProjectId );
+            BuildDefinition buildDef = projectsBuildDefinitionsMap.get( firstBuildableProject.getId() );
 
-            if ( buildDef.getArguments() == null || buildDef.getBuildFile() == null || buildDef.getGoals() == null ||
-                buildDef.getSchedule() == null )
+            if ( buildDef.getSchedule() == null )
             {
-                log.error( "Null values set on build definition (id=" + buildDef.getId() + ")" );
-                throw new BuildManagerException( "Unable to build project due to null values set on " +
-                                                     "( GOALS , ARGUMENTS , BUILD_FILE, SCHEDULE_ID_OID ) of BUILDDEFINITION ID : " +
-                                                     buildDef.getId() + " Please notify your system adminitrator" );
+                String msg = String.format( "Invalid data, null schedule for builddef id=%s/project id=%s",
+                                            buildDef.getId(), firstBuildableProject.getId() );
+                log.error( msg );
+                throw new BuildManagerException( msg + ", please notify your system adminitrator" );
             }
             OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectsInGroupAreQueued( projectGroupId );
 
@@ -239,7 +241,16 @@ public class ParallelBuildsManager
                                                                        buildTrigger, project.getName(),
                                                                        buildDefinitionLabel, scmResult,
                                                                        projectGroupId );
-                    buildTask.setMaxExecutionTime( buildDefinition.getSchedule().getMaxJobExecutionTime() * 1000 );
+
+                    if ( buildDefinition.getSchedule() == null )
+                    {
+                        log.warn( String.format( "Invalid data, null schedule for builddef id=%s/project id=%s",
+                                                 buildDef.getId(), project.getId() ) );
+                    }
+                    else
+                    {
+                        buildTask.setMaxExecutionTime( buildDefinition.getSchedule().getMaxJobExecutionTime() * 1000 );
+                    }
 
                     try
                     {