示例#1
0
        private static BuildStatus?GetStatus(Api.Models.Build build)
        {
            switch (build.State)
            {
            case Api.Models.BuildState.Queued:
                return(BuildStatus.Queued);

            case Api.Models.BuildState.Running:
                return(BuildStatus.InProgress);

            case Api.Models.BuildState.Finished:
                switch (build.Status)
                {
                case Api.Models.BuildStatus.Success:
                    return(BuildStatus.Succeeded);

                case Api.Models.BuildStatus.Failure:
                case Api.Models.BuildStatus.Error:
                    return(BuildStatus.Failed);

                default:
                    return(null);
                }

            default:
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Build" /> class.
        /// </summary>
        /// <param name="build">The build.</param>
        public Build(Api.Models.Build build)
        {
            Ensure.That(build).IsNotNull();

            Id          = build.Id;
            Number      = build.Number;
            Version     = null;
            Branch      = build.BranchName;
            StartTime   = build.StartDate?.ToUniversalTime();
            EndTime     = build.FinishDate?.ToUniversalTime();
            Status      = GetStatus(build);
            RequestedBy = GetRequestedBy(build);
            WebUrl      = build.WebUrl;
            Changes     = build.LastChanges?.Change.Select(change => new Change(change.Version, change.Date?.ToUniversalTime(), change.Username, change.Comment?.Trim())).ToArray() ?? new IChange[] { };
        }
示例#3
0
 private static string GetRequestedBy(Api.Models.Build build)
 {
     return(build.Triggered?.User?.Username);
 }