throw new ContinuumException( "The URL to the site is not defined." );
}
Repository repository = new Repository( id, url );
Wagon wagon;
try
{
wagon = wagonManager.getWagon( repository.getProtocol() );
}
catch ( UnsupportedProtocolException e )
{
throw new ContinuumException( "Unsupported protocol: '" + repository.getProtocol() + "'", e );
}
if ( !wagon.supportsDirectoryCopy() )
{
throw new ContinuumException(
"Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
}
try
{
if ( log.isDebugEnabled() )
{
Debug debug = new Debug();
wagon.addSessionListener( debug );
wagon.addTransferListener( debug );
}
ProxyInfo proxyInfo = getProxyInfo( repository );
if ( proxyInfo != null )
{
wagon.connect( repository, getAuthenticationInfo( id ), proxyInfo );
}
else
{
wagon.connect( repository, getAuthenticationInfo( id ) );
}
File buildOutputFile = configurationService.getBuildOutputFile( build.getId(), build.getProject().getId() );
wagon.put( buildOutputFile, BUILD_OUTPUT_FILE_NAME );
// TODO: current wagon uses zip which will use the umask on remote host instead of honouring our settings
// Force group writeable
if ( wagon instanceof CommandExecutor )
{
CommandExecutor exec = (CommandExecutor) wagon;
exec.executeCommand( "chmod -Rf g+w " + repository.getBasedir() );
}
}
catch ( ConfigurationException e )
{
throw new ContinuumException( "Error uploading build results to deployed site.", e );
}
catch ( ResourceDoesNotExistException e )
{
throw new ContinuumException( "Error uploading site", e );
}
catch ( TransferFailedException e )
{
throw new ContinuumException( "Error uploading site", e );
}
catch ( AuthorizationException e )
{
throw new ContinuumException( "Error uploading site", e );
}
catch ( ConnectionException e )
{
throw new ContinuumException( "Error uploading site", e );
}
catch ( AuthenticationException e )
{
throw new ContinuumException( "Error uploading site", e );
}
catch ( CommandExecutionException e )
{
throw new ContinuumException( "Error uploading site", e );
}
finally
{
try
{
wagon.disconnect();
}
catch ( ConnectionException e )
{
log.error( "Error disconnecting wagon - ignored", e );
}