public CommandExecutorInteractive(
     CommandArguments args,
     IScriptProvider scriptProvider,
     IFlubuSession flubuSession,
     ITargetCreator targetCreator,
     IScriptProperties scriptProperties,
     ILogger <CommandExecutorInteractive> log,
     IFlubuTemplateTasksExecutor flubuTemplateTasksExecutor)
     : base(flubuSession, args, flubuTemplateTasksExecutor)
 {
     _scriptProvider   = scriptProvider;
     _flubuSession     = flubuSession;
     _targetCreator    = targetCreator;
     _scriptProperties = scriptProperties;
     _log = log;
 }
예제 #2
0
        public TargetCreatorTests()
        {
            var sp = new ServiceCollection().AddTransient <ITarget, TargetFluentInterface>()
                     .AddTransient <ICoreTaskFluentInterface, CoreTaskFluentInterface>()
                     .AddTransient <ITaskFluentInterface, TaskFluentInterface>()
                     .AddTransient <ILinuxTaskFluentInterface, LinuxTaskFluentInterface>()
                     .AddTransient <IIisTaskFluentInterface, IisTaskFluentInterface>()
                     .AddTransient <IWebApiFluentInterface, WebApiFluentInterface>()
                     .AddTransient <IGitFluentInterface, GitFluentInterface>()
                     .AddTransient <DockerFluentInterface>()
                     .AddTransient <IToolsFluentInterface, ToolsFluentInterface>()
                     .AddSingleton <IHttpClientFactory, HttpClientFactory>()
                     .BuildServiceProvider();

            _flubuSession  = new FlubuSession(new Mock <ILogger <FlubuSession> >().Object, new TargetTree(null, null), new CommandArguments(), new ScriptServiceProvider(sp), new Mock <ITaskFactory>().Object, new FluentInterfaceFactory(sp), null, null);
            _targetCreator = new TargetCreator();
        }
예제 #3
0
        public int Run(IFlubuSession flubuSession)
        {
            _flubuSession     = flubuSession;
            _scriptProperties = flubuSession.ScriptFactory.CreateScriptProperties();
            _targetCreator    = flubuSession.ScriptFactory.CreateTargetCreator();

            try
            {
                ConfigureDefaultProps(flubuSession);
                BeforeBuildExecution(flubuSession);
                RunBuild(flubuSession);
                flubuSession.Complete();
                AfterBuildExecution(flubuSession);
                return(0);
            }
            catch (TargetNotFoundException e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);
                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                flubuSession.LogError($"{Environment.NewLine}{e.Message}");
                return(3);
            }
            catch (WebApiException e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);
                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                return(1);
            }
            catch (FlubuException e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);

                if (!flubuSession.Args.RethrowOnException)
                {
#if !NETSTANDARD1_6
                    flubuSession.LogError($"ERROR: {e.Message}", Color.Red);
#else
                    flubuSession.LogError($"error: {e.Message}");
#endif
                }

                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                return(1);
            }
            catch (Exception e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);

                if (!flubuSession.Args.RethrowOnException)
                {
#if !NETSTANDARD1_6
                    flubuSession.LogError($"ERROR: {e}", Color.Red);
#else
                    flubuSession.LogError($"error: {e}");
#endif
                }

                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                return(2);
            }
        }
예제 #4
0
        public int Run(IFlubuSession flubuSession)
        {
            _flubuSession       = flubuSession;
            _scriptProperties   = flubuSession.ScriptServiceProvider.GetScriptProperties();
            _targetCreator      = flubuSession.ScriptServiceProvider.GetTargetCreator();
            _flubuConfiguration = flubuSession.ScriptServiceProvider.GetFlubuConfiguration();

            try
            {
                ConfigureDefaultProps(flubuSession);
                BeforeBuildExecution(flubuSession);
                RunBuild(flubuSession);
                flubuSession.Complete();
                AfterBuildExecution(flubuSession);
                return(0);
            }
            catch (TargetNotFoundException e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);
                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                flubuSession.LogError($"{Environment.NewLine}{e.Message}");
                return(3);
            }
            catch (WebApiException e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);
                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                return(1);
            }
            catch (FlubuException e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);

                if (!flubuSession.Args.RethrowOnException)
                {
                    flubuSession.LogError($"ERROR: {e.Message}", Color.Red);
                }

                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                return(1);
            }
            catch (Exception e)
            {
                flubuSession.ResetDepth();
                OnBuildFailed(flubuSession, e);

                if (!flubuSession.Args.RethrowOnException)
                {
                    flubuSession.LogError($"ERROR: {e}", Color.Red);
                }

                AfterBuildExecution(flubuSession);
                if (flubuSession.Args.RethrowOnException)
                {
                    throw;
                }

                return(2);
            }
        }