// ----------------------------------------------------------------------
// Make the buildResult
// ----------------------------------------------------------------------
BuildResult buildResult = new BuildResult();
buildResult.setStartTime( new Date().getTime() );
buildResult.setState( ContinuumProjectState.BUILDING );
buildResult.setTrigger( trigger );
buildResult.setUsername( username );
buildResult.setBuildDefinition( buildDefinition );
buildResult.setScmResult( ContinuumBuildAgentUtil.getScmResult( context, null ) );
context.put( ContinuumBuildAgentUtil.KEY_BUILD_RESULT, buildResult );
try
{
File buildOutputFile = buildAgentConfigurationService.getBuildOutputFile( project.getId() );
ContinuumAgentBuildExecutionResult result = buildExecutor.build( project, buildDefinition, buildOutputFile,
environments, localRepository );
buildResult.setState( result.getExitCode() == 0 ? ContinuumProjectState.OK : ContinuumProjectState.FAILED );
buildResult.setExitCode( result.getExitCode() );
}
catch ( ContinuumAgentBuildCancelledException e )
{
getLogger().info( "Cancelled build" );
buildResult.setState( ContinuumProjectState.CANCELLED );
}
catch ( Throwable e )
{
getLogger().error( "Error running buildResult", e );
buildResult.setState( ContinuumProjectState.ERROR );
buildResult.setError( ContinuumBuildAgentUtil.throwableToString( e ) );
}
finally
{
buildResult.setEndTime( new Date().getTime() );
if ( buildResult.getState() != ContinuumProjectState.OK &&
buildResult.getState() != ContinuumProjectState.FAILED &&
buildResult.getState() != ContinuumProjectState.ERROR &&
buildResult.getState() != ContinuumProjectState.CANCELLED )
{
buildResult.setState( ContinuumProjectState.ERROR );
}
context.put( ContinuumBuildAgentUtil.KEY_BUILD_RESULT, buildResult );
}
}