private int InvokeScript(CalamariVariableDictionary variables)
        {
            var validatedScriptFilePath = AssertScriptFileExists();

            var scriptEngine = new CombinedScriptEngine();
            var runner       = new CommandLineRunner(
                new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables)));

            Log.VerboseFormat("Executing '{0}'", validatedScriptFilePath);
            var result             = scriptEngine.Execute(new Script(validatedScriptFilePath, scriptParameters), variables, runner);
            var shouldWriteJournal = CanWriteJournal(variables) && deployment != null && !deployment.SkipJournal;

            if (result.ExitCode == 0 && result.HasErrors && variables.GetFlag(SpecialVariables.Action.FailScriptOnErrorOutput, false))
            {
                if (shouldWriteJournal)
                {
                    journal.AddJournalEntry(new JournalEntry(deployment, false));
                }

                return(-1);
            }

            if (shouldWriteJournal)
            {
                journal.AddJournalEntry(new JournalEntry(deployment, true));
            }

            return(result.ExitCode);
        }
示例#2
0
        private int InvokeScript(CalamariVariableDictionary variables)
        {
            var validatedScriptFilePath = AssertScriptFileExists();

            var scriptEngine = new CombinedScriptEngine();
            var runner       = new CommandLineRunner(
                new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables)));
            var result = scriptEngine.Execute(validatedScriptFilePath, variables, runner);

            return(result.ExitCode);
        }
示例#3
0
        private int InvokeScript(CalamariVariableDictionary variables)
        {
            if (!File.Exists(scriptFile))
            {
                throw new CommandException("Could not find script file: " + scriptFile);
            }

            var scriptEngine = new CombinedScriptEngine();
            var runner       = new CommandLineRunner(
                new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables)));
            var result = scriptEngine.Execute(scriptFile, variables, runner);

            return(result.ExitCode);
        }
示例#4
0
        private int InvokeScript(CalamariVariableDictionary variables)
        {
            var validatedScriptFilePath = AssertScriptFileExists();

            var scriptEngine = new CombinedScriptEngine();
            var runner       = new CommandLineRunner(
                new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables)));

            Log.VerboseFormat("Executing '{0}'", validatedScriptFilePath);
            var result = scriptEngine.Execute(new Script(validatedScriptFilePath, scriptParameters), variables, runner);

            if (result.ExitCode == 0 && result.HasErrors && variables.GetFlag(SpecialVariables.Action.FailScriptOnErrorOutput, false))
            {
                return(-1);
            }

            return(result.ExitCode);
        }
示例#5
0
        public override int Execute(string[] commandLineArguments)
        {
            Options.Parse(commandLineArguments);

            variables.EnrichWithEnvironmentVariables();
            variables.LogVariables();

            var runner = new CommandLineRunner(new ConsoleCommandOutput());

            Log.VerboseFormat("Executing '{0}'", scriptFile);
            var result = scriptEngine.Execute(new Script(scriptFile, ""), variables, runner);

            if (result.ExitCode == 0 && result.HasErrors && variables.GetFlag(SpecialVariables.Action.FailScriptOnErrorOutput, false))
            {
                return(-1);
            }

            return(result.ExitCode);
        }
示例#6
0
        private int InvokeScript(string scriptFileName, CalamariVariableDictionary variables)
        {
            // Any additional files extracted from the packages or sent by the action handler are processed here
            SubstituteVariablesInAdditionalFiles();

            var scriptParameters = variables.Get(SpecialVariables.Action.Script.ScriptParameters);

            if (WasProvided(scriptParametersArg) && WasProvided(scriptParameters))
            {
                Log.Warn($"The `--scriptParameters` parameter and `{SpecialVariables.Action.Script.ScriptParameters}` variable are both set.\r\n" +
                         $"Please provide just the `{SpecialVariables.Action.Script.ScriptParameters}` variable instead.");
            }

            var runner = new CommandLineRunner(new SplitCommandOutput(new ConsoleCommandOutput(), new ServiceMessageCommandOutput(variables)));

            Log.VerboseFormat("Executing '{0}'", scriptFileName);
            var result = scriptEngine.Execute(new Script(scriptFileName, scriptParametersArg ?? scriptParameters), variables, runner);

            var shouldWriteJournal = CanWriteJournal(variables) && deployment != null && !deployment.SkipJournal;

            if (result.ExitCode == 0 && result.HasErrors && variables.GetFlag(SpecialVariables.Action.FailScriptOnErrorOutput, false))
            {
                if (shouldWriteJournal)
                {
                    journal.AddJournalEntry(new JournalEntry(deployment, false));
                }

                return(-1);
            }

            if (shouldWriteJournal)
            {
                journal.AddJournalEntry(new JournalEntry(deployment, true));
            }

            return(result.ExitCode);
        }