Exemple #1
0
        private bool DoExecute(ProcessedArgs args, ILogger logger)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            logger.Verbosity = VerbosityCalculator.ComputeVerbosity(args.AggregateProperties, logger);

            InstallLoaderTargets(args, logger);

            TeamBuildSettings teamBuildSettings = TeamBuildSettings.GetSettingsFromEnvironment(logger);

            // We're checking the args and environment variables so we can report all
            // config errors to the user at once
            if (teamBuildSettings == null)
            {
                logger.LogError(Resources.ERROR_CannotPerformProcessing);
                return(false);
            }

            // Create the directories
            logger.LogDebug(Resources.MSG_CreatingFolders);
            if (!Utilities.TryEnsureEmptyDirectories(logger,
                                                     teamBuildSettings.SonarConfigDirectory,
                                                     teamBuildSettings.SonarOutputDirectory))
            {
                return(false);
            }

            IDictionary <string, string> serverSettings;

            if (!FetchArgumentsAndRulesets(args, teamBuildSettings.SonarConfigDirectory, logger, out serverSettings))
            {
                return(false);
            }

            AnalysisConfigGenerator.GenerateFile(args, teamBuildSettings, serverSettings, logger);

            return(true);
        }
        private bool DoExecute(ProcessedArgs localSettings)
        {
            Debug.Assert(localSettings != null, "Not expecting the process arguments to be null");

            this.logger.Verbosity = VerbosityCalculator.ComputeVerbosity(localSettings.AggregateProperties, this.logger);
            logger.ResumeOutput();

            InstallLoaderTargets(localSettings);

            TeamBuildSettings teamBuildSettings = TeamBuildSettings.GetSettingsFromEnvironment(this.logger);

            // We're checking the args and environment variables so we can report all config errors to the user at once
            if (teamBuildSettings == null)
            {
                this.logger.LogError(Resources.ERROR_CannotPerformProcessing);
                return(false);
            }

            // Create the directories
            this.logger.LogDebug(Resources.MSG_CreatingFolders);
            if (!Utilities.TryEnsureEmptyDirectories(this.logger,
                                                     teamBuildSettings.SonarConfigDirectory,
                                                     teamBuildSettings.SonarOutputDirectory))
            {
                return(false);
            }

            ISonarQubeServer server = this.factory.CreateSonarQubeServer(localSettings, this.logger);

            IDictionary <string, string> serverSettings;
            List <AnalyzerSettings>      analyzersSettings;

            if (!FetchArgumentsAndRulesets(server, localSettings, teamBuildSettings, out serverSettings, out analyzersSettings))
            {
                return(false);
            }
            Debug.Assert(analyzersSettings != null, "Not expecting the analyzers settings to be null");

            // analyzerSettings can be empty
            AnalysisConfigGenerator.GenerateFile(localSettings, teamBuildSettings, serverSettings, analyzersSettings, this.logger);

            return(true);
        }