BuildDefinition buildDefinition = ContinuumBuildAgentUtil.getBuildDefinition( context );
UpdateScmResult scmResult;
ScmResult result;
try
{
// TODO: not sure why this is different to the context, but it all needs to change
File workingDirectory = buildAgentConfigurationService.getWorkingDirectory( project.getId() );
ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory );
//config.setLatestUpdateDate( latestUpdateDate );
String tag = config.getTag();
String msg = project.getName() + "', id: '" + project.getId() + "' to '" +
workingDirectory.getAbsolutePath() + "'" + ( tag != null ? " with branch/tag " + tag + "." : "." );
getLogger().info( "Updating project: " + msg );
scmResult = scm.update( config );
if ( !scmResult.isSuccess() )
{
getLogger().warn( "Error while updating the code for project: '" + msg );
getLogger().warn( "Command output: " + scmResult.getCommandOutput() );
getLogger().warn( "Provider message: " + scmResult.getProviderMessage() );
}
if ( scmResult.getUpdatedFiles() != null && scmResult.getUpdatedFiles().size() > 0 )
{
getLogger().info( "Updated " + scmResult.getUpdatedFiles().size() + " files." );
}
result = convertScmResult( scmResult );
}
catch ( ScmRepositoryException e )
{
result = new ScmResult();
result.setSuccess( false );
result.setProviderMessage( e.getMessage() + ": " + getValidationMessages( e ) );
getLogger().error( e.getMessage(), e);
}
catch ( NoSuchScmProviderException e )
{
// TODO: this is not making it back into a result of any kind - log it at least. Same is probably the case for ScmException
result = new ScmResult();
result.setSuccess( false );
result.setProviderMessage( e.getMessage() );
getLogger().error( e.getMessage(), e);
}
catch ( ScmException e )
{
result = new ScmResult();
result.setSuccess( false );
result.setException( ContinuumBuildAgentUtil.throwableMessagesToString( e ) );
getLogger().error( e.getMessage(), e);
}
context.put( ContinuumBuildAgentUtil.KEY_UPDATE_SCM_RESULT, result );