예제 #1
0
        } // class BuildLogDetail

        static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                BuildLogDetail buildLogDetail = new BuildLogDetail(arg);
                Console.WriteLine("{0}", arg);
                try
                {
                    Console.WriteLine("    \"{0}\"", buildLogDetail.LastErrorDataLine());
                    // " ()+-,"
                    string lastErrorDataLine = buildLogDetail.LastErrorDataLine();
                    Regex  regex             = new Regex("([A-Z, ]+[a-z, ]+[0-9, ]+\\(\\))+");
                    Match  match             = regex.Match(lastErrorDataLine);
                    if (match.Success)
                    {
                        Console.WriteLine("Match is \"{0}\"", lastErrorDataLine.Substring(match.Index, match.Length));
                    }

                    Console.WriteLine("    {0}", (buildLogDetail.Succeeded() ? "++++ Succeeded" : "---- Failed"));
                }
                catch (BuildLogDetail.BuildLogIsBusyException eek)
                {
                    Console.WriteLine("    \"{0}\" is busy", arg);
                }
                catch (Exception eek)
                {
                    Console.WriteLine("    Exception : {0}", eek.ToString());
                }
            }
        }
예제 #2
0
        public async Task <List <BuildLogDetail> > GetBuildLogs(string projectName, int BuildId)
        {
            List <BuildLogDetail> buildLogs      = new List <BuildLogDetail>();
            BuildLogDetail        buildLogDetail = new BuildLogDetail();
            ResultModel           resultModel    = new ResultModel();
            DevOpsConnectionPool  poolObj        = _builderPool.Get();

            try
            {
                var buildclient = new BuildHttpClient(new Uri(poolObj.CollUrl), poolObj.VssCredentials);

                var result = await buildclient.GetBuildLogsAsync(projectName, BuildId);

                if (result != null && result.Count > 0)
                {
                    foreach (var log in result)
                    {
                        buildLogDetail           = new BuildLogDetail();
                        buildLogDetail.Id        = log.Id;
                        buildLogDetail.Url       = log.Url;
                        buildLogDetail.CreatedOn = log.CreatedOn;
                        resultModel = await GetLogContents(projectName, BuildId, log.Id, buildclient);

                        if (resultModel != null)
                        {
                            buildLogDetail.IsError     = resultModel.IsError;
                            buildLogDetail.HtmlContent = resultModel.HtmContent;
                            buildLogDetail.TaskName    = resultModel.TaskName;
                            buildLogDetail.TaskColor   = resultModel.TaskColor;
                        }
                        buildLogs.Add(buildLogDetail);
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                _builderPool.Return(poolObj);
            }
            return(buildLogs);
        }