log.info( "update build result of project '" + projectId + "'" );
Project project = projectDao.getProjectWithAllDetails( projectId );
BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
BuildResult oldBuildResult =
buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
int buildNumber;
if ( ContinuumBuildConstant.getBuildState( context ) == ContinuumProjectState.OK )
{
buildNumber = project.getBuildNumber() + 1;
}
else
{
buildNumber = project.getBuildNumber();
}
// ----------------------------------------------------------------------
// Make the buildResult
// ----------------------------------------------------------------------
BuildResult buildResult = distributedBuildUtil.convertMapToBuildResult( context );
if ( buildResult.getState() != ContinuumProjectState.CANCELLED )
{
buildResult.setBuildDefinition( buildDefinition );
buildResult.setBuildNumber( buildNumber );
buildResult.setModifiedDependencies( distributedBuildUtil.getModifiedDependencies( oldBuildResult, context ) );
buildResult.setScmResult( distributedBuildUtil.getScmResult( context ) );
Date date = ContinuumBuildConstant.getLatestUpdateDate( context );
if ( date != null )
{
buildResult.setLastChangedDate( date.getTime() );
}
else if ( oldBuildResult != null )
{
buildResult.setLastChangedDate( oldBuildResult.getLastChangedDate() );
}
buildResultDao.addBuildResult( project, buildResult );
project.setOldState( project.getState() );
project.setState( ContinuumBuildConstant.getBuildState( context ) );
project.setBuildNumber( buildNumber );
project.setLatestBuildId( buildResult.getId() );
}
else
{
project.setState( project.getOldState() );
project.setOldState( 0 );
}
projectDao.updateProject( project );
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();
if ( buildResult.getState() != ContinuumProjectState.CANCELLED )
{
notifierDispatcher.buildComplete( project, buildDefinition, buildResult );
}
}
catch ( ContinuumStoreException e )