{
continue;
}
int buildDefinitionId = projectsAndBuildDefinitions.get( project.getId() );
BuildDefinition buildDef = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( project.getId() );
Map<String, Object> context = new HashMap<String, Object>();
context.put( ContinuumBuildConstant.KEY_PROJECT_GROUP_ID, project.getProjectGroup().getId() );
context.put( ContinuumBuildConstant.KEY_PROJECT_GROUP_NAME, project.getProjectGroup().getName() );
context.put( ContinuumBuildConstant.KEY_SCM_ROOT_ID, scmRootId );
context.put( ContinuumBuildConstant.KEY_SCM_ROOT_ADDRESS, scmRootAddress );
context.put( ContinuumBuildConstant.KEY_PROJECT_ID, project.getId() );
context.put( ContinuumBuildConstant.KEY_PROJECT_NAME, project.getName() );
context.put( ContinuumBuildConstant.KEY_PROJECT_VERSION, project.getVersion() );
context.put( ContinuumBuildConstant.KEY_EXECUTOR_ID, project.getExecutorId() );
context.put( ContinuumBuildConstant.KEY_PROJECT_BUILD_NUMBER, project.getBuildNumber() );
context.put( ContinuumBuildConstant.KEY_SCM_URL, project.getScmUrl() );
context.put( ContinuumBuildConstant.KEY_PROJECT_STATE, project.getState() );
if ( buildResult != null )
{
context.put( ContinuumBuildConstant.KEY_LATEST_UPDATE_DATE,
new Date( buildResult.getStartTime() ) );
}
LocalRepository localRepo = project.getProjectGroup().getLocalRepository();
if ( localRepo != null )
{
context.put( ContinuumBuildConstant.KEY_LOCAL_REPOSITORY, localRepo.getLocation() );
}
else
{
context.put( ContinuumBuildConstant.KEY_LOCAL_REPOSITORY, "" );
}
if ( project.getScmUsername() == null )
{
context.put( ContinuumBuildConstant.KEY_SCM_USERNAME, "" );
}
else
{
context.put( ContinuumBuildConstant.KEY_SCM_USERNAME, project.getScmUsername() );
}
if ( project.getScmPassword() == null )
{
context.put( ContinuumBuildConstant.KEY_SCM_PASSWORD, "" );
}
else
{
context.put( ContinuumBuildConstant.KEY_SCM_PASSWORD, project.getScmPassword() );
}
if ( project.getScmTag() != null )
{
context.put( ContinuumBuildConstant.KEY_SCM_TAG, project.getScmTag() );
}
else
{
context.put( ContinuumBuildConstant.KEY_SCM_TAG, "" );
}
context.put( ContinuumBuildConstant.KEY_BUILD_DEFINITION_ID, buildDefinitionId );
String buildDefinitionLabel = buildDef.getDescription();
if ( StringUtils.isEmpty( buildDefinitionLabel ) )
{
buildDefinitionLabel = buildDef.getGoals();
}
context.put( ContinuumBuildConstant.KEY_BUILD_DEFINITION_LABEL, buildDefinitionLabel );
context.put( ContinuumBuildConstant.KEY_BUILD_FILE, buildDef.getBuildFile() );
context.put( ContinuumBuildConstant.KEY_GOALS, buildDef.getGoals() );
if ( buildDef.getArguments() == null )
{
context.put( ContinuumBuildConstant.KEY_ARGUMENTS, "" );
}
else
{
context.put( ContinuumBuildConstant.KEY_ARGUMENTS, buildDef.getArguments() );
}
context.put( ContinuumBuildConstant.KEY_TRIGGER, trigger );
context.put( ContinuumBuildConstant.KEY_BUILD_FRESH, buildDef.isBuildFresh() );
context.put( ContinuumBuildConstant.KEY_ALWAYS_BUILD, buildDef.isAlwaysBuild() );
context.put( ContinuumBuildConstant.KEY_OLD_SCM_CHANGES,
getOldScmChanges( project.getId(), buildDefinitionId ) );
context.put( ContinuumBuildConstant.KEY_BUILD_AGENT_URL, buildAgentUrl );
context.put( ContinuumBuildConstant.KEY_MAX_JOB_EXEC_TIME,
buildDef.getSchedule().getMaxJobExecutionTime() );
buildContext.add( context );
}
return buildContext;