コード例 #1
0
 /// <summary>
 /// Prepares the given target path for deployment. If clean target is false, it does nothing.
 /// </summary>
 /// <param name="sftpClient">The SFTP client.</param>
 /// <param name="verbOptions">The verb options.</param>
 private static void PrepareTargetPath(SftpClient sftpClient, CliExecuteOptionsBase verbOptions)
 {
     if (!verbOptions.CleanTarget)
     {
         return;
     }
     Terminal.WriteLine($"    Cleaning Target Path '{verbOptions.TargetPath}'", ConsoleColor.Green);
     DeleteLinuxDirectoryRecursive(sftpClient, verbOptions.TargetPath);
 }
コード例 #2
0
        /// <summary>
        /// Creates the given directory structure on the target machine.
        /// </summary>
        /// <param name="sftpClient">The SFTP client.</param>
        /// <param name="verbOptions">The verb options.</param>
        private static void CreateTargetPath(SftpClient sftpClient, CliExecuteOptionsBase verbOptions)
        {
            if (sftpClient.Exists(verbOptions.TargetPath))
            {
                return;
            }

            Terminal.WriteLine($"    Target Path '{verbOptions.TargetPath}' does not exist. -- Will attempt to create.", ConsoleColor.Green);
            CreateLinuxDirectoryRecursive(sftpClient, verbOptions.TargetPath);
            Terminal.WriteLine($"    Target Path '{verbOptions.TargetPath}' created successfully.", ConsoleColor.Green);
        }
コード例 #3
0
        /// <summary>
        /// Runs pre and post deployment commands over the SSH client.
        /// </summary>
        /// <param name="shellStream">The shell stream.</param>
        /// <param name="verbOptions">The verb options.</param>
        private static void RunShellStreamCommand(ShellStream shellStream, CliExecuteOptionsBase verbOptions)
        {
            var commandText = verbOptions.PostCommand;

            if (string.IsNullOrWhiteSpace(commandText))
            {
                return;
            }

            Terminal.WriteLine("    Executing shell command.", ConsoleColor.Green);
            shellStream.Write($"{commandText}\r\n");
            shellStream.Flush();
            Terminal.WriteLine($"    TX: {commandText}", ConsoleColor.DarkYellow);
        }
コード例 #4
0
        /// <summary>
        /// Runs the deployment command.
        /// </summary>
        /// <param name="sshClient">The SSH client.</param>
        /// <param name="verbOptions">The verb options.</param>
        private static void RunSshClientCommand(SshClient sshClient, CliExecuteOptionsBase verbOptions)
        {
            var commandText = verbOptions.PreCommand;

            if (string.IsNullOrWhiteSpace(commandText))
            {
                return;
            }

            "    Executing SSH client command.".WriteLine(ConsoleColor.Green);
            var result = sshClient.RunCommand(commandText);

            $"    SSH TX: {commandText}".WriteLine(ConsoleColor.DarkYellow);
            $"    SSH RX: [{result.ExitStatus}] {result.Result}".WriteLine(ConsoleColor.DarkYellow);
        }