public static bool CloneRepository( BuildConfiguration buildConfiguration, Build build, string repositoryOwnerDirectory, string repositoryDirectory, Action<string> log) { log("STEP: Cloning repository."); Func<bool> step = () => { log("Checking whether repository has already been cloned."); if (Directory.Exists(repositoryDirectory)) { log(String.Format("{0} already exists. Skipping clone.", repositoryDirectory)); return true; } var url = GetRepositoryUrl(buildConfiguration.Owner, buildConfiguration.Name, buildConfiguration.Token); using (var process = CreateProcess( command: "git.exe", arguments: String.Format("clone --recursive {0} {1}", url, repositoryDirectory), workingDirectory: repositoryOwnerDirectory)) { return RunProcess(process, log) == 0; } }; return RunStep(step, log); }
public static bool SetGitHubBuildFinished( BuildConfiguration buildConfiguration, Build build, bool succeeded, Action<string> logBuildMessage) { var state = succeeded ? CommitState.Success : CommitState.Failure; var stateName = Enum.GetName(typeof(CommitState), state); logBuildMessage(String.Format("STEP: Updating GitHub build status to {0}.", stateName)); return RunStep(() => { if (buildConfiguration.Token == null) { logBuildMessage("The build configuration has no token; skipping."); return true; } if (build.Revision == null) { logBuildMessage("The build has no SHA; skipping."); return true; } SetGitHubBuildStatus(build, state); return true; }, logBuildMessage); }
static object CreateBuildsResponseModel(BuildConfiguration buildConfiguration) { return fn.GetBuilds(buildConfiguration.Owner, buildConfiguration.Name) .Reverse() .Select(build => new { id = build.Id, description = fn.GetBuildDescription(build, true), status = GetBuildStatus(build) }); }
public static bool SetGitHubBuildStarted( BuildConfiguration buildConfiguration, Build build, Action<string> logBuildMessage) { logBuildMessage("STEP: Setting GitHub build status to Pending."); return RunStep(() => { if (buildConfiguration.Token == null) { logBuildMessage("The build configuration has no token; skipping."); return true; } SetGitHubBuildStatus(build, CommitState.Pending); return true; }, logBuildMessage); }