Example #1
0
        public string GetCachedCommentForBuild(TfsJsonBuild build)
        {
            var buildDefinition       = build.Definition.Id;
            var cachedCommentForBuild = _commentsCache[buildDefinition];

            return(cachedCommentForBuild.Item2);
        }
Example #2
0
        public async Task <List <TfsJsonComment> > GetComments(TfsJsonBuild tfsJsonBuild, TfsConnectionDetails connection, string projectCollection)
        {
            var comments = await GetFromTfs <TfsJsonComment>(connection, $"{projectCollection}/_apis/build/builds/{tfsJsonBuild.Id}/changes",
                                                             new Dictionary <string, string>());

            return(comments);
        }
        private async Task <string> GetCommentOnce(TfsJsonBuild tfsJsonBuild, TfsConnectionDetails connection, string projectCollection)
        {
            var comments = await _tfsJsonService.GetComments(tfsJsonBuild, connection, projectCollection);

            var firstComment = comments.FirstOrDefault();
            var message      = firstComment?.Message;

            return(message);
        }
 public TfsRestBuildStatus(TfsJsonBuild tfsRestBuildDefinition, CommentsCache commentsCache)
 {
     BuildStatusEnum   = GetBuildStatus(tfsRestBuildDefinition);
     Name              = tfsRestBuildDefinition.Definition.Name;
     BuildDefinitionId = tfsRestBuildDefinition.Definition.Id.ToString();
     RequestedBy       = tfsRestBuildDefinition.RequestedFor?.DisplayName;
     BuildId           = tfsRestBuildDefinition.Id.ToString();
     Url     = tfsRestBuildDefinition._links.Web.Href;
     Comment = commentsCache.GetCachedCommentForBuild(tfsRestBuildDefinition);
 }
        private static BuildStatusEnum GetBuildStatus(TfsJsonBuild tfsRestBuildDefinition)
        {
            if (tfsRestBuildDefinition.Status == "inProgress")
            {
                return(BuildStatusEnum.InProgress);
            }
            BuildStatusEnum buildStatusEnum;

            return(_buildStatusMapping.TryGetValue(tfsRestBuildDefinition.Result, out buildStatusEnum) ? buildStatusEnum : BuildStatusEnum.Unknown);
        }
        private async Task <string> GetComment(TfsJsonBuild tfsJsonBuild, TfsConnectionDetails connection, string projectCollection)
        {
            var message = await GetCommentOnce(tfsJsonBuild, connection, projectCollection);

            if (tfsJsonBuild.Definition.Type == "xaml" && message == null)
            {
                // old style xaml builds don't get associated with a commit immediately for some annoying reason, so keep trying for 2 minutes
                const int maxRetries = 12;
                for (int i = 0; i < maxRetries && message == null; i++)
                {
                    _log.Debug("Comment was null for a xaml build definition, so delaying and checking for a comment again in 10 seconds");
                    await Task.Delay(10000);

                    message = await GetCommentOnce(tfsJsonBuild, connection, projectCollection);
                }
            }
            return(message?.Trim());
        }
Example #7
0
        private async Task FetchAndSaveComment(Func <TfsJsonBuild, Task <string> > getCommentFunc, TfsJsonBuild tfsJsonBuild)
        {
            var buildDefinitionId = tfsJsonBuild.Definition.Id;
            var buildId           = tfsJsonBuild.Id;
            var comment           = await getCommentFunc(tfsJsonBuild); // comment is null here

            _commentsCache[buildDefinitionId] = new Tuple <int, string>(buildId, comment);
        }