// ----------------------------------------------------------------------
// Check out the project
// ----------------------------------------------------------------------
ScmResult result;
try
{
String scmUserName = getScmUsername( context, project.getScmUsername() );
String scmPassword = getScmPassword( context, project.getScmPassword() );
ContinuumScmConfiguration config =
createScmConfiguration( project, workingDirectory, scmUserName, scmPassword );
String tag = config.getTag();
getLogger().info(
"Checking out project: '" + project.getName() + "', id: '" + project.getId() + "' " + "to '" +
workingDirectory + "'" + ( tag != null ? " with branch/tag " + tag + "." : "." ) );
CheckOutScmResult checkoutResult = scm.checkout( config );
if ( StringUtils.isNotEmpty( checkoutResult.getRelativePathProjectDirectory() ) )
{
context.put( KEY_PROJECT_RELATIVE_PATH, checkoutResult.getRelativePathProjectDirectory() );
}
if ( !checkoutResult.isSuccess() )
{
// TODO: is it more appropriate to return this in the converted result so that it can be presented to
// the user?
String msg = "Error while checking out the code for project: '" + project.getName() + "', id: '" +
project.getId() + "' to '" + workingDirectory.getAbsolutePath() + "'" +
( tag != null ? " with branch/tag " + tag + "." : "." );
getLogger().warn( msg );
getLogger().warn( "Command output: " + checkoutResult.getCommandOutput() );
getLogger().warn( "Provider message: " + checkoutResult.getProviderMessage() );
}
else
{
getLogger().info( "Checked out " + checkoutResult.getCheckedOutFiles().size() + " files." );
}
result = convertScmResult( checkoutResult );
}
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( ContinuumUtils.throwableMessagesToString( e ) );
getLogger().error( e.getMessage(), e );
}
catch ( Throwable t )
{
// TODO: do we want this here, or should it be to the logs?
// TODO: what throwables do we really get here that we can cope with?
result = new ScmResult();
result.setSuccess( false );
result.setException( ContinuumUtils.throwableMessagesToString( t ) );
getLogger().error( t.getMessage(), t );
}
finally
{