예제 #1
0
        public static int Execute(string[] args, IBuildAgentUpdater updater, ILogger logger)
        {
            int exitCode;

            IBootstrapperSettings settings;

            if (ArgumentProcessor.TryProcessArgs(args, logger, out settings))
            {
                Debug.Assert(settings != null, "Bootstrapper settings should not be null");
                Debug.Assert(settings.Phase != AnalysisPhase.Unspecified, "Expecting the processing phase to be specified");

                logger.Verbosity = settings.LoggingVerbosity;

                AnalysisPhase phase = settings.Phase;
                LogProcessingStarted(phase, logger);

                if (phase == AnalysisPhase.PreProcessing)
                {
                    exitCode = PreProcess(updater, settings, logger);
                }
                else
                {
                    exitCode = PostProcess(settings, logger);
                }

                LogProcessingCompleted(phase, exitCode, logger);
            }
            else
            {
                // The argument processor will have logged errors
                exitCode = ErrorCode;
            }
            return(exitCode);
        }
예제 #2
0
        public static int Main(string[] args)
        {
            var logger = new ConsoleLogger();

            Utilities.LogAssemblyVersion(logger, typeof(Program).Assembly, Resources.AssemblyDescription);
            IBootstrapperSettings settings;

            if (ArgumentProcessor.IsHelp(args))
            {
                logger.LogInfo("");
                logger.LogInfo("Usage: ");
                logger.LogInfo("");
                logger.LogInfo("  {0} [begin|end] /key:project_key [/name:project_name] [/version:project_version] [/d:sonar.key=value] [/s:settings_file]", System.AppDomain.CurrentDomain.FriendlyName);
                logger.LogInfo("");
                logger.LogInfo("    When executing the begin phase, at least the project key must be defined.");
                logger.LogInfo("    Other properties can dynamically be defined with '/d:'. For example, '/d:sonar.verbose=true'.");
                logger.LogInfo("    A settings file can be used to define properties. If no settings file path is given, the file SonarQube.Analysis.xml in the installation directory will be used.");
                logger.LogInfo("    Only the token should be passed during the end phase, if it was used during the begin phase.");

                return(SuccessCode);
            }

            if (!ArgumentProcessor.TryProcessArgs(args, logger, out settings))
            {
                // The argument processor will have logged errors
                return(ErrorCode);
            }

            IProcessorFactory processorFactory = new DefaultProcessorFactory(logger);
            BootstrapperClass bootstrapper     = new BootstrapperClass(processorFactory, settings, logger);

            return(bootstrapper.Execute());
        }
예제 #3
0
        public static int Execute(string[] args, ILogger logger)
        {
            logger.SuspendOutput();

            if (ArgumentProcessor.IsHelp(args))
            {
                logger.LogInfo("");
                logger.LogInfo("Usage: ");
                logger.LogInfo("");
                logger.LogInfo("  {0} [begin|end] /key:project_key [/name:project_name] [/version:project_version] [/d:sonar.key=value] [/s:settings_file]", System.AppDomain.CurrentDomain.FriendlyName);
                logger.LogInfo("");
                logger.LogInfo("    When executing the begin phase, at least the project key must be defined.");
                logger.LogInfo("    Other properties can dynamically be defined with '/d:'. For example, '/d:sonar.verbose=true'.");
                logger.LogInfo("    A settings file can be used to define properties. If no settings file path is given, the file SonarQube.Analysis.xml in the installation directory will be used.");
                logger.LogInfo("    Only the token should be passed during the end phase, if it was used during the begin phase.");

                logger.ResumeOutput();
                return(SuccessCode);
            }

            if (!ArgumentProcessor.TryProcessArgs(args, logger, out IBootstrapperSettings settings))
            {
                logger.ResumeOutput();
                // The argument processor will have logged errors
                Environment.ExitCode = ErrorCode;
                return(ErrorCode);
            }

            IProcessorFactory processorFactory = new DefaultProcessorFactory(logger);
            var bootstrapper = new BootstrapperClass(processorFactory, settings, logger);
            var exitCode     = bootstrapper.Execute();

            Environment.ExitCode = exitCode;
            return(exitCode);
        }
예제 #4
0
        public static int Main(string[] args)
        {
            var logger = new ConsoleLogger();

            Utilities.LogAssemblyVersion(logger, typeof(Program).Assembly, Resources.AssemblyDescription);
            IBootstrapperSettings settings;

            if (!ArgumentProcessor.TryProcessArgs(args, logger, out settings))
            {
                // The argument processor will have logged errors
                return(ErrorCode);
            }

            IProcessorFactory processorFactory = new DefaultProcessorFactory(logger);
            BootstrapperClass bootstrapper     = new BootstrapperClass(processorFactory, settings, logger);

            return(bootstrapper.Execute());
        }