private async Task <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);
            this.logger.ResumeOutput();

            InstallLoaderTargets(localSettings);

            var 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);
            }

            var server = this.factory.CreateSonarQubeServer(localSettings);

            //TODO: fail fast after release of 6.0
            //Deprecation notice for SQ < 7.9
            await server.WarnIfSonarQubeVersionIsDeprecated();

            try
            {
                if (!await server.IsServerLicenseValid())
                {
                    this.logger.LogError(Resources.ERR_UnlicensedServer, localSettings.SonarQubeUrl);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                this.logger.LogError(ex.Message);
                return(false);
            }

            var argumentsAndRuleSets = await FetchArgumentsAndRulesets(server, localSettings, teamBuildSettings);

            if (!argumentsAndRuleSets.IsSuccess)
            {
                return(false);
            }
            Debug.Assert(argumentsAndRuleSets.AnalyzersSettings != null, "Not expecting the analyzers settings to be null");

            // analyzerSettings can be empty
            AnalysisConfigGenerator.GenerateFile(localSettings, teamBuildSettings, argumentsAndRuleSets.ServerSettings, argumentsAndRuleSets.AnalyzersSettings, server, this.logger);

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

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

            InstallLoaderTargets(localSettings);

            var 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);
            }

            var server = factory.CreateSonarQubeServer(localSettings);

            if (!FetchArgumentsAndRulesets(server, localSettings, teamBuildSettings, out IDictionary <string, string> serverSettings, out List <AnalyzerSettings> 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, server, logger);

            return(true);
        }