Exemplo n.º 1
0
        public async Task ThreaxDockerToolsRun(String file, String content)
        {
            int exitCode;
            var tempFile = pathHelper.GetTempProvisionPath();

            try
            {
                File.WriteAllText(tempFile, content);

                var tempLoc = $"~/{Path.GetFileName(tempFile)}";
                await sshCredsManager.CopySshFile(tempFile, tempLoc);

                exitCode = await sshCredsManager.RunSshCommand($"sudo mkdir \"{Path.GetDirectoryName(file).Replace('\\', '/')}\"");

                exitCode = await sshCredsManager.RunSshCommand($"sudo mv \"{tempLoc}\" \"{file}\"");

                if (exitCode != 0)
                {
                    throw new InvalidOperationException($"Error moving the file.");
                }

                exitCode = await sshCredsManager.RunSshCommand($"sudo /app/.tools/Threax.DockerTools/bin/Threax.DockerTools run {file}");

                if (exitCode != 0)
                {
                    throw new InvalidOperationException($"Error during docker tools run.");
                }
            }
            finally
            {
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            }
        }