示例#1
0
 public List <BuildServerExecutionInfo> GetAllPrevSuccessInfos(BuildServerExecutionInfo executionInfo)
 {
     return(this.AllExecInfos
            .Where(x => x.JobName == executionInfo.JobName && x.JobNum < executionInfo.JobNum)
            .OrderByDescending(x => x.JobNum)
            .TakeWhile(x => x.Status != EnumJobStatus.Success)
            .ToList());
 }
示例#2
0
 public void CopyFrom([NotNull] BuildServerExecutionInfo executionInfo)
 {
     this.JobName        = executionInfo.JobName;
     this.JobNum         = executionInfo.JobNum;
     this.Status         = executionInfo.Status;
     this.JobDescription = executionInfo.JobDescription;
     this.LastRefreshJob = executionInfo.LastRefreshJob;
     this.ChangeSet      = executionInfo.ChangeSet;
 }
示例#3
0
        private async Task <BuildServerExecutionInfo> PaseSingleJob([NotNull] string jobName,
                                                                    Tuple <int, bool, string> updateJobInfo)
        {
            //http://208.0.0.1:8081/job/FbpfTestPromDump/249/api/xml
            //http://208.0.0.1:8081/job/AsudTestPromDump/247/api/xml?tree=building,displayName,fullDisplayName,changeSets[items[comment]]
            var request = this.CreateRequest("/job/" + jobName + "/" + updateJobInfo.Item1 +
                                             "/api/xml?tree=description,building,displayName,fullDisplayName,changeSets[items[comment]]");

            using (var response = (HttpWebResponse)(await request.GetResponseAsync()))
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    return(null);
                }

                var execInfo = new BuildServerExecutionInfo();

                execInfo.JobName        = jobName;
                execInfo.JobNum         = updateJobInfo.Item1;
                execInfo.LastRefreshJob = DateTime.Now;
                switch (updateJobInfo.Item3)
                {
                case "SUCCESS":
                    execInfo.Status = EnumJobStatus.Success;
                    break;

                case "FAILURE":
                    execInfo.Status = EnumJobStatus.Fail;
                    break;

                case "ABORTED":
                    execInfo.Status = EnumJobStatus.Aborted;
                    break;

                default:
                    execInfo.Status = EnumJobStatus.Undef;
                    break;
                }

                if (updateJobInfo.Item2)
                {
                    execInfo.Status = EnumJobStatus.InProgress;
                }

                var xDoc = await XDocument.LoadAsync(response.GetResponseStream(), LoadOptions.None,
                                                     CancellationToken.None);

                var xRoot = xDoc.Element("workflowRun") ?? throw new NotSupportedException("Не нашли корень");


                var xDesc = xRoot.Element("description");
                if (xDesc != null)
                {
                    execInfo.JobDescription = xDesc.Value;
                }

                var xChangeSet = xRoot.Element("changeSet");
                if (xChangeSet != null)
                {
                    foreach (var xChSetItem in xChangeSet.Elements("item"))
                    {
                        var xChangeComment = xChSetItem.Element("comment");
                        if (xChangeComment != null)
                        {
                            execInfo.ChangeSet.Add(xChangeComment.Value.EscapeHtml());
                        }
                    }
                }

                return(execInfo);
            }
        }