{
for ( Integer buildDefId : buildDefIds )
{
if ( isProjectOkToBuild( project.getId(), buildDefId ) )
{
ProjectScmRoot scmRoot = getProjectScmRootByProject( project.getId() );
Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRoot );
if ( projectsAndBuildDefinitionsMap == null )
{
projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
}
projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
map.put( scmRoot, projectsAndBuildDefinitionsMap );
if ( !sortedScmRoot.contains( scmRoot ) )
{
sortedScmRoot.add( scmRoot );
}
}
else
{
log.info(
"Not queueing the build with projectId={} and buildDefinitionId={} because it is already building",
projectId, buildDefId );
}
}
}
}
BuildTrigger buildTrigger = new BuildTrigger( ContinuumProjectState.TRIGGER_SCHEDULED, schedule.getName() );
for ( ProjectScmRoot scmRoot : sortedScmRoot )
{
try
{
prepareBuildProjects( map.get( scmRoot ), buildTrigger, scmRoot.getScmRootAddress(),
scmRoot.getProjectGroup().getId(), scmRoot.getId(), sortedScmRoot );
}
catch ( NoBuildAgentException e )
{
log.error( "Unable to build projects in project group " + scmRoot.getProjectGroup().getName() +
" because there is no build agent configured" );
}
catch ( NoBuildAgentInGroupException e )
{
log.error( "Unable to build projects in project group " + scmRoot.getProjectGroup().getName() +
" because there is no build agent configured in build agent group" );
}
}
}