Package org.apache.maven.continuum.model.scm

Examples of org.apache.maven.continuum.model.scm.ScmResult


        BuildDefinition buildDefinition = getBuildDefinition( context );

        UpdateScmResult scmResult;

        ScmResult result;

        Date latestUpdateDate = null;

        int originalState = project.getState();

        project.setState( ContinuumProjectState.UPDATING );

        projectDao.updateProject( project );

        try
        {
            BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( project.getId() );

            latestUpdateDate = new Date( buildResult.getStartTime() );
        }
        catch ( Exception e )
        {
        }

        try
        {
            notifier.checkoutStarted( project, buildDefinition );

            // TODO: not sure why this is different to the context, but it all needs to change
            File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
            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( ContinuumUtils.throwableMessagesToString( e ) );

            getLogger().error( e.getMessage(), e );
        }
        finally
        {
View Full Code Here


        return config;
    }

    private ScmResult convertScmResult( UpdateScmResult scmResult )
    {
        ScmResult result = new ScmResult();

        result.setCommandLine( maskPassword( scmResult.getCommandLine() ) );

        result.setSuccess( scmResult.isSuccess() );

        result.setCommandOutput( scmResult.getCommandOutput() );

        result.setProviderMessage( scmResult.getProviderMessage() );

        if ( scmResult.getChanges() != null && !scmResult.getChanges().isEmpty() )
        {
            for ( org.apache.maven.scm.ChangeSet scmChangeSet : (List<org.apache.maven.scm.ChangeSet>) scmResult.getChanges() )
            {
                ChangeSet change = new ChangeSet();

                change.setAuthor( scmChangeSet.getAuthor() );

                change.setComment( scmChangeSet.getComment() );

                if ( scmChangeSet.getDate() != null )
                {
                    change.setDate( scmChangeSet.getDate().getTime() );
                }

                if ( scmChangeSet.getFiles() != null )
                {
                    for ( org.apache.maven.scm.ChangeFile f : (List<org.apache.maven.scm.ChangeFile>) scmChangeSet.getFiles() )
                    {
                        ChangeFile file = new ChangeFile();

                        file.setName( f.getName() );

                        file.setRevision( f.getRevision() );

                        change.addFile( file );
                    }
                }

                result.addChange( change );
            }
        }
        else
        {
            // We don't have a changes information probably because provider doesn't have a changelog command
            // so we use the updated list that contains only the updated files list
            ChangeSet changeSet = convertScmFileSetToChangeSet( scmResult.getUpdatedFiles() );

            if ( changeSet != null )
            {
                result.addChange( changeSet );
            }

        }

        return result;
View Full Code Here

        BuildDefinition buildDefinition = getBuildDefinition( context );

        BuildTrigger buildTrigger = getBuildTrigger( context );

        ScmResult scmResult = getScmResult( context );

        List<ProjectDependency> updatedDependencies = getUpdatedDependencies( context );

        ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
View Full Code Here

        {
            // ----------------------------------------------------------------------
            //
            // ----------------------------------------------------------------------

            ScmResult scmResult = CheckoutProjectContinuumAction.getCheckoutResult( context, null );

            Project project = projectDao.getProject( getProjectId( context ) );

            project.setCheckoutResult( scmResult );
View Full Code Here

        // ----------------------------------------------------------------------
        // 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
        {
View Full Code Here

        return config;
    }

    private ScmResult convertScmResult( CheckOutScmResult scmResult )
    {
        ScmResult result = new ScmResult();

        result.setSuccess( scmResult.isSuccess() );

        result.setCommandLine( maskPassword( scmResult.getCommandLine() ) );

        result.setCommandOutput( scmResult.getCommandOutput() );

        result.setProviderMessage( scmResult.getProviderMessage() );

        return result;
    }
View Full Code Here

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        ScmResult scmResult = new ScmResult();

        scmResult.setSuccess( true );

        scmResult.setCommandOutput( "commandOutput" );

        scmResult.setProviderMessage( "providerMessage" );

        project.setCheckoutResult( scmResult );

        defaultProjectGroup.addProject( project );
View Full Code Here

        // Make a new descriptor
        // ----------------------------------------------------------------------

        ContinuumBuildExecutor builder = buildExecutorManager.getBuildExecutor( project.getExecutorId() );

        ScmResult scmResult = (ScmResult) context.get( "scmResult" );
        builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project ), project,
                                           buildDefinition, scmResult );

        // ----------------------------------------------------------------------
        // Store the new descriptor
View Full Code Here

    private BuildContext getContext()
        throws Exception
    {
        return controller.initializeBuildContext( projectId2, buildDefinitionId2,
                          new BuildTrigger( ContinuumProjectState.TRIGGER_SCHEDULED, "" ), new ScmResult() );
    }
View Full Code Here

    {
        BuildContext context = getContext();
        BuildResult oldBuildResult = new BuildResult();
        oldBuildResult.setEndTime( Calendar.getInstance().getTimeInMillis() + ( hourOfLastExecution * 3600000 ) );
        context.setOldBuildResult( oldBuildResult );
        context.setScmResult( new ScmResult() );
        return context;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.continuum.model.scm.ScmResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.