private async Task NotifyGithubComplete(ProjectGithubSource githubSource) { if (SourceCommit == null) { Log.Error("Unable to send GitHub notification! Commit is undefined!"); return; } var status = new CommitStatus { Context = "Photon", }; if (Exception != null) { status.State = CommitStates.Failure; status.Description = "Build Failed!"; } else { status.State = CommitStates.Success; status.Description = "Build Successful."; } await GetStatusUpdater(githubSource).Post(status); }
private CommitStatusUpdater GetStatusUpdater(ProjectGithubSource githubSource) { return(new CommitStatusUpdater { Username = githubSource.Username, Password = githubSource.Password, StatusUrl = SourceCommit.StatusesUrl, Sha = SourceCommit.Sha, }); }
private async Task NotifyGithubStarted(ProjectGithubSource githubSource) { if (SourceCommit == null) { Log.Error("Unable to send GitHub notification! Commit is undefined!"); return; } var status = new CommitStatus { State = CommitStates.Pending, Context = "Photon", Description = "Build in progress..." }; await GetStatusUpdater(githubSource).Post(status); }
private void ApplyGithubNotification(ServerBuildSession session, ProjectGithubSource source, GithubCommit commit) { var su = new CommitStatusUpdater { Username = source.Username, Password = source.Password, StatusUrl = commit.StatusesUrl, Sha = commit.Sha, }; session.PreBuildEvent += (o, e) => { var status = new CommitStatus { State = CommitStates.Pending, Context = "Photon", Description = "Build in progress..." }; su.Post(status).GetAwaiter().GetResult(); }; session.PostBuildEvent += (o, e) => { var status = new CommitStatus { Context = "Photon", }; if (session.Result.Cancelled) { status.State = CommitStates.Error; status.Description = "The build was cancelled."; } else if (session.Result.Successful) { status.State = CommitStates.Success; status.Description = $"Build Successful. {session.Result.Message}"; } else { status.State = CommitStates.Failure; status.Description = $"Build Failed! {session.Result.Message}"; } su.Post(status).GetAwaiter().GetResult(); }; }