Exemple #1
0
        public Task Run()
        {
            var clonePath  = appConfig.ClonePath;
            var dockerFile = Path.GetFullPath(Path.Combine(clonePath, appConfig.Dockerfile ?? throw new InvalidOperationException($"Please provide {nameof(appConfig.Dockerfile)} when using build.")));
            var image      = appConfig.Name;
            var buildTag   = appConfig.GetBuildTag();
            var currentTag = appConfig.GetCurrentTag();

            var args = $"build {clonePath} -f {dockerFile} -t {image}:{buildTag} -t {image}:{currentTag}";

            if (appConfig.AlwaysPull)
            {
                args += " --pull";
            }

            processRunner.RunProcessWithOutput(new ProcessStartInfo("docker", args));

            return(Task.CompletedTask);
        }
Exemple #2
0
        public Task <GitRepo> Add(GitRepoInput gitRepo)
        {
            string fullPath = GetRepoPath(gitRepo.Name);

            if (Directory.Exists(fullPath))
            {
                throw new InvalidOperationException($"A repository named '{gitRepo.Name}' already exists.");
            }

            Directory.CreateDirectory(fullPath);
            var startInfo = new ProcessStartInfo("git", "init --bare");

            startInfo.WorkingDirectory = fullPath;
            var result = processRunner.RunProcessWithOutput(startInfo);

            if (result != 0)
            {
                throw new InvalidOperationException($"Error initializing git repository '{gitRepo.Name}'.");
            }

            var dirInfo = new DirectoryInfo(fullPath);

            return(Task.FromResult(GetGitRepoInfo(dirInfo)));
        }
Exemple #3
0
        public Task <int> RunSshCommand(String command)
        {
            var startInfo = new ProcessStartInfo("ssh", $"-t \"{host}\" -p {port} \"{command}\"");

            return(Task.FromResult(processRunner.RunProcessWithOutput(startInfo)));
        }