public CheckinInfo GetCheckinInfo(IBuildDetail buildDetail, BuildStatus buildStatus, MyTfsBuildDefinition buildDefinition) { // Start with some semi-reasonable defaults for comment and author, but we'll try a variety of things to make them better var result = new CheckinInfo(buildDetail); var changesets = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_CHANGESET); var commits = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_COMMIT); var anyGitChangesets = changesets.Any(); var anyTfsCommits = commits.Any(); if (anyGitChangesets) { // This path does not not require a network call. It is used when the build is not in progress and the project uses git source control result = SetInfoFromAssociatedChangesets(changesets); } else if (anyTfsCommits) { // This path does not not require a network call. It is used when the build is not in progress and the project uses tfs (non-git) source control result = SetInfoFromAssociatedCommits(commits); } else { // this path may require a network call, however we cache requests. It is used the first time an in-progress build is found var latestChangeset = QueryServerForLatestChangesetButCache(buildDefinition, buildStatus); if (latestChangeset != null) { result.Committer = latestChangeset.Committer; result.Comment = latestChangeset.Comment; } } return result; }
private static BuildStatus CreateBuildStatus(IBuildDetail buildDetail, MyTfsBuildDefinition myTfsBuildDefinition) { return(new BuildStatus { BuildDefinitionId = buildDetail.BuildDefinition.Name, Name = buildDetail.BuildDefinition.Name, BuildStatusEnum = GetBuildStatusEnum(buildDetail.Status), RequestedBy = buildDetail.RequestedFor, StartedTime = buildDetail.StartTime == DateTime.MinValue ? (DateTime?)null : buildDetail.StartTime, FinishedTime = buildDetail.FinishTime == DateTime.MinValue ? (DateTime?)null : buildDetail.FinishTime, Url = myTfsBuildDefinition.ConvertTfsUriToUrl(buildDetail.Uri) }); }
private static CheckinInfo QueryServerForLatestChangesetButCache(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus) { var newBuildHash = buildStatus.GetBuildDataAsHash(); CommentAndHash cachedChangeset; bool haveEverGottenCommentsForThisBuildDef = _cachedCommentsByBuildDefinition.TryGetValue(buildDefinition.Name, out cachedChangeset); bool areCacheCommentsStale = false; if (haveEverGottenCommentsForThisBuildDef) { string oldBuildHash = cachedChangeset.BuildStatusHash; areCacheCommentsStale = oldBuildHash != newBuildHash; } if (!haveEverGottenCommentsForThisBuildDef || areCacheCommentsStale) { CheckinInfo latestChangeset = buildDefinition.GetLatestChangeset(); _cachedCommentsByBuildDefinition[buildDefinition.Name] = new CommentAndHash(newBuildHash, latestChangeset); } return _cachedCommentsByBuildDefinition[buildDefinition.Name].Changeset; }
private MyChangeset GetCommentsForBuild(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus) { var newBuildHash = buildStatus.GetBuildDataAsHash(); CommentAndHash cachedChangeset; bool haveEverGottenCommentsForThisBuildDef = CachedCommentsByBuildDefinition.TryGetValue(buildDefinition.Name, out cachedChangeset); bool areCacheCommentsStale = false; if (haveEverGottenCommentsForThisBuildDef) { string oldBuildHash = cachedChangeset.BuildStatusHash; areCacheCommentsStale = oldBuildHash != newBuildHash; } if (!haveEverGottenCommentsForThisBuildDef || areCacheCommentsStale) { MyChangeset latestChangeset = buildDefinition.GetLatestChangeset(); CachedCommentsByBuildDefinition[buildDefinition.Name] = new CommentAndHash(newBuildHash, latestChangeset); } return(CachedCommentsByBuildDefinition[buildDefinition.Name].Changeset); }
public BuildStatus GetCommentsIntoBuildStatus(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus) { MyChangeset changeset = GetCommentsForBuild(buildDefinition, buildStatus); return(AddCommentsToBuildStatus(buildStatus, changeset)); }
public BuildStatus GetCommentsIntoBuildStatus(MyTfsBuildDefinition buildDefinition, BuildStatus buildStatus) { MyChangeset changeset = GetCommentsForBuild(buildDefinition, buildStatus); return AddCommentsToBuildStatus(buildStatus, changeset); }
private static BuildStatus CreateBuildStatus(IBuildDetail buildDetail, MyTfsBuildDefinition myTfsBuildDefinition, bool applyBuildQuality) { return new BuildStatus { BuildDefinitionId = buildDetail.BuildDefinition.Name, Name = buildDetail.BuildDefinition.Name, BuildStatusEnum = GetBuildStatusEnum(buildDetail, applyBuildQuality), RequestedBy = buildDetail.RequestedFor, StartedTime = buildDetail.StartTime == DateTime.MinValue ? (DateTime?)null : buildDetail.StartTime, FinishedTime = buildDetail.FinishTime == DateTime.MinValue ? (DateTime?)null : buildDetail.FinishTime, Url = myTfsBuildDefinition.ConvertTfsUriToUrl(buildDetail.Uri) }; }
private static void SetCheckinInfo(IBuildDetail buildDetail, bool applyBuildQuality, BuildStatus result, BuildStatusEnum buildQuality, MyTfsBuildDefinition buildDefinition) { var checkinInfoGetterService = new CheckinInfoGetterService(); var checkinInfo = checkinInfoGetterService.GetCheckinInfo(buildDetail, result, buildDefinition); if (checkinInfo != null) { result.Comment = checkinInfo.Comment; result.RequestedBy = checkinInfo.Committer; } if (applyBuildQuality && buildQuality == BuildStatusEnum.Broken) { result.Comment = "Build deployment or test failure. Please see test server or test results for details.\n" + result.Comment; } }
public CheckinInfo GetCheckinInfo(IBuildDetail buildDetail, BuildStatus buildStatus, MyTfsBuildDefinition buildDefinition) { // Start with some semi-reasonable defaults for comment and author, but we'll try a variety of things to make them better var result = new CheckinInfo(buildDetail); var changesets = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_CHANGESET); var commits = buildDetail.Information.GetNodesByType(MyBuildServer.ASSOCIATED_COMMIT); var anyGitChangesets = changesets.Any(); var anyTfsCommits = commits.Any(); if (anyGitChangesets) { // This path does not not require a network call. It is used when the build is not in progress and the project uses git source control result = SetInfoFromAssociatedChangesets(changesets); } else if (anyTfsCommits) { // This path does not not require a network call. It is used when the build is not in progress and the project uses tfs (non-git) source control result = SetInfoFromAssociatedCommits(commits); } else { // this path may require a network call, however we cache requests. It is used the first time an in-progress build is found var latestChangeset = QueryServerForLatestChangesetButCache(buildDefinition, buildStatus); if (latestChangeset != null) { result.Committer = latestChangeset.Committer; result.Comment = latestChangeset.Comment; } } return(result); }