예제 #1
0
        private void Init(AbstractBuild hudsonBuild, TestResult testResult)
        {
            if (testResult != null)
            {
                this.TestsFailed = testResult.FailCount;
                this.TestsPassed = testResult.PassCount;

                int skipped = testResult.SkipCount;

                this.TestsTotal = skipped + this.TestsFailed + this.TestsPassed;
            }

            this.BuildFinished = !hudsonBuild.Building;
            var timeStampInMilliseconds = hudsonBuild.Timestamp.ToString().Substring(0, 10);

            this.StartTime = Epoch.AddSeconds(long.Parse(timeStampInMilliseconds, CultureInfo.InvariantCulture));
            this.FinishTime = this.StartTime.Value.AddMilliseconds(hudsonBuild.Duration);
            this.Status = this.BuildFinished ? GetBuildStatusFromResult(hudsonBuild.Result) : BuildStatus.InProgress;

            if (hudsonBuild.Culprit == null || hudsonBuild.Culprit.Length == 0)
            {
                this.RequestedFor = "anonymous";
            }
            else
            {
                this.RequestedFor = hudsonBuild.Culprit[0].FullName;
            }
        }
예제 #2
0
        private void Init(AbstractBuild hudsonBuild, TestResult testResult)
        {
            if (testResult != null)
            {
                this.TestsFailed = testResult.FailCount;
                this.TestsPassed = testResult.PassCount;

                int skipped = testResult.SkipCount;

                this.TestsTotal = skipped + this.TestsFailed + this.TestsPassed;
            }

            this.BuildFinished = !hudsonBuild.Building;
            var timeStampInMilliseconds = hudsonBuild.Timestamp.ToString().Substring(0, 10);

            this.StartTime  = Epoch.AddSeconds(long.Parse(timeStampInMilliseconds, CultureInfo.InvariantCulture));
            this.FinishTime = this.StartTime.Value.AddMilliseconds(hudsonBuild.Duration);
            this.Status     = this.BuildFinished ? GetBuildStatusFromResult(hudsonBuild.Result) : BuildStatus.InProgress;

            if (hudsonBuild.Culprit == null || hudsonBuild.Culprit.Length == 0)
            {
                this.RequestedFor = "anonymous";
            }
            else
            {
                this.RequestedFor = hudsonBuild.Culprit[0].FullName;
            }
        }
예제 #3
0
        public static AbstractBuild Get(string hudsonUri, string name)
        {
            var           client = new WebClient();
            AbstractBuild build  = null;

            try
            {
                var buildString =
                    client.DownloadString(hudsonUri + "job/" + Uri.EscapeUriString(name) + "/lastBuild/api/xml");

                var reader = new StringReader(buildString);

                if (buildString.StartsWith("<freeStyleBuild>"))
                {
                    build = new FreeStyleBuild();
                    var serializer = new XmlSerializer(build.GetType());
                    build = (FreeStyleBuild)serializer.Deserialize(reader);
                }
                else if (buildString.StartsWith("<matrixBuild>"))
                {
                    build = new MatrixBuild();
                    var serializer = new XmlSerializer(build.GetType());
                    build = (MatrixBuild)serializer.Deserialize(reader);
                }
                else
                {
                    var buildType = buildString.Substring(1, buildString.IndexOf('>'));
                    throw new NotSupportedException(string.Format("Unrecognised build type '{0}'", buildType));
                }
            }
            catch (WebException wex)
            {
                if (wex.Status == WebExceptionStatus.ProtocolError)
                {
                    if (((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound)
                    {
                        // 404
                        return(null);
                    }
                }
            }

            return(build);
        }
예제 #4
0
 public HudsonBuildInfo(AbstractBuild hudsonBuild, TestResult testResult)
 {
     this.Init(hudsonBuild, testResult);
 }
예제 #5
0
 public HudsonBuildInfo(AbstractBuild hudsonBuild, TestResult testResult)
 {
     this.Init(hudsonBuild, testResult);
 }