Browse files

Merge pull request #1 from phil-b-higgins/master

Fixes for Jenkins API
  • Loading branch information...
2 parents d4da690 + f14b36b commit aa699bad3543fae3d46e8ef18e784a120868bc58 @flipbit committed Feb 29, 2012
View
29 .gitignore
@@ -0,0 +1,29 @@
+
+#ignore thumbnails created by windows
+Thumbs.db
+#Ignore files build by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
View
2 Source/Hudson.Core/Domain/Build.cs
@@ -11,7 +11,7 @@ public class Build : BuildDescriptor
/// Gets or sets the revision.
/// </summary>
/// <value>The revision.</value>
- public int Revision { get; set; }
+ public string Revision { get; set; }
/// <summary>
/// Gets or sets the created.
View
8 Source/Hudson.Core/Extensions/FindExtension.cs
@@ -21,6 +21,14 @@ public static int FindInteger(this XmlNode xml, string xpath)
return int.TryParse(valueAsString, out value) ? value : 0;
}
+ public static string FindLast(this XmlNode xml, string xpath)
+ {
+ var selectedNodes = xml.SelectNodes(xpath);
+
+ return selectedNodes == null || selectedNodes.Count == 0 ?
+ String.Empty :
+ selectedNodes[selectedNodes.Count - 1].InnerText;
+ }
/// <summary>
/// Finds the given node and returns it as a <see cref="Uri"/> object.
View
31 Source/Hudson.Core/Mappers/BuildMapper.cs
@@ -21,20 +21,20 @@ public Build Map(XmlDocument xml)
if (xml != null)
{
- build = new Build();
+ build = new Build
+ {
+ Description = xml.Find("//shortDescription"),
+ Building = bool.Parse(xml.Find("//building")),
+ Duration = xml.FindInteger("//duration"),
+ FullDisplayName = xml.Find("//fullDisplayName"),
+ KeepLog = bool.Parse(xml.Find("//keepLog")),
+ Number = xml.FindInteger("//number"),
+ Success = xml.Find("//result") == "SUCCESS",
+ Url = new Uri(xml.Find("//url")),
+ User = xml.FindLast("//author//fullName")
+ };
// Hudson Properties
- build.Description = xml.Find("//shortDescription");
- build.Building = bool.Parse(xml.Find("//building"));
- build.Duration = xml.FindInteger("//duration");
- build.FullDisplayName = xml.Find("//fullDisplayName");
- build.KeepLog = bool.Parse(xml.Find("//keepLog"));
- build.Number = xml.FindInteger("//number");
- build.Success = xml.Find("//result") == "SUCCESS";
- build.Url = new Uri(xml.Find("//url"));
- build.User = xml.Find("//user");
-
-
DateTime created;
@@ -47,9 +47,10 @@ public Build Map(XmlDocument xml)
build.Created = JavaTimeStampToDateTime(seconds);
- // SVN Properties
- build.Revision = xml.FindInteger("//revision");
- build.Comments = xml.Find("//msg");
+ // GIT Properties
+ var rev = xml.Find("//lastBuiltRevision//SHA1");
+ build.Revision = rev.Length > 5 ? rev.Substring(0, 5) : rev;
+ build.Comments = xml.FindLast("//msg");
}
return build;
View
23 Source/Hudson.Core/Mappers/JobDescriptorMapper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Xml;
using Hudson.Domain;
using Hudson.Extensions;
@@ -25,19 +26,15 @@ public IList<JobDescriptor> Map(XmlDocument xml)
if (nodes != null)
{
- foreach (XmlNode node in nodes)
- {
- var xmlNode = node.CloneNode(true);
-
- var descriptor = new JobDescriptor
- {
- Name = xmlNode.Find("//name"),
- Url = new Uri(xmlNode.Find("//url")),
- Status = BuildStatusParser.Parse(xmlNode.Find("//color"))
- };
-
- descriptors.Add(descriptor);
- }
+ descriptors.AddRange(
+ nodes.Cast<XmlNode>()
+ .Select(node => node.CloneNode(true))
+ .Select(xmlNode => new JobDescriptor
+ {
+ Name = xmlNode.Find("//name"),
+ Url = new Uri(xmlNode.Find("//url")),
+ Status = BuildStatusParser.Parse(xmlNode.Find("//color"))
+ }));
}
return descriptors;
View
29 Source/Hudson.Core/Mappers/JobMapper.cs
@@ -21,20 +21,21 @@ public Job Map(XmlDocument xml)
if (xml != null)
{
- job = new Job();
-
- job.Name = xml.Find("//name");
- job.Description = xml.Find("//description");
- job.DisplayName = xml.Find("//displayName");
- job.Url = xml.FindUri("//url");
- job.Buildable = bool.Parse(xml.Find("//buildable"));
- job.BuildStatus = BuildStatusParser.Parse(xml.Find("//color"));
- job.HealthReport = xml.Find("//healthReport/description");
- job.IconUrl = xml.Find("//healthReport/iconUrl");
- job.Score = xml.FindInteger("//healthReport/score");
- job.InQueue = bool.Parse(xml.Find("//inQueue"));
- job.KeepDependencies = bool.Parse(xml.Find("//keepDependencies"));
- job.NextBuildNumber = xml.FindInteger("//nextBuildNumber");
+ job = new Job
+ {
+ Name = xml.Find("//name"),
+ Description = xml.Find("//description"),
+ DisplayName = xml.Find("//displayName"),
+ Url = xml.FindUri("//url"),
+ Buildable = bool.Parse(xml.Find("//buildable")),
+ BuildStatus = BuildStatusParser.Parse(xml.Find("//color")),
+ HealthReport = xml.Find("//healthReport/description"),
+ IconUrl = xml.Find("//healthReport/iconUrl"),
+ Score = xml.FindInteger("//healthReport/score"),
+ InQueue = bool.Parse(xml.Find("//inQueue")),
+ KeepDependencies = bool.Parse(xml.Find("//keepDependencies")),
+ NextBuildNumber = xml.FindInteger("//nextBuildNumber")
+ };
}
return job;
View
8 Source/Hudson.Core/Mappers/ServerMapper.cs
@@ -21,10 +21,10 @@ public Server Map(XmlDocument xml)
if (xml != null)
{
server = new Server
- {
- Description = xml.Find("//description"),
- Url = xml.FindUri("//url")
- };
+ {
+ Description = xml.Find("//description"),
+ Url = xml.FindUri("//url")
+ };
}
return server;
View
5 Source/Hudson.Core/Services/XmlService.cs
@@ -2,7 +2,6 @@
using System.IO;
using System.Net;
using System.Text;
-using System.Windows.Forms;
using Hudson.Core;
using Hudson.Domain;
using Hudson.Interfaces;
@@ -35,10 +34,12 @@ public XmlPage GetPage(Uri url)
var request = WebRequest.Create(url);
request.Method = "GET";
- request.Timeout = 10000;
+ request.Timeout = 90000;
if (Context.RequireAuthentication)
{
+ request.PreAuthenticate = true;
+
var authInfo = Context.Username + ":" + Context.Password;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
View
13 Source/Hudson.Test/Mappers/BuildMapperTest.cs
@@ -24,17 +24,18 @@ public void TestMapBuild()
Assert.IsNotNull(build);
- Assert.AreEqual("Started by user", build.Description);
+ Assert.AreEqual("Started by an SCM change", build.Description);
Assert.AreEqual(true, build.Building);
- Assert.AreEqual(28204, build.Duration);
+ Assert.AreEqual(811570, build.Duration);
Assert.AreEqual("first-job #92", build.FullDisplayName);
Assert.AreEqual(false, build.KeepLog);
- Assert.AreEqual("Changed account.", build.Comments);
- Assert.AreEqual(92, build.Number);
- Assert.AreEqual(119, build.Revision);
+ Assert.AreEqual("Fixed stuff.", build.Comments);
+ Assert.AreEqual(1124, build.Number);
+ Assert.AreEqual("fa882", build.Revision);
Assert.AreEqual(true, build.Success);
Assert.AreEqual("http://www.example.com/job/first-job/92/", build.Url.ToString());
- Assert.AreEqual(DateTime.Parse("2009-06-21 18:49:37"), build.Created);
+ Assert.AreEqual(DateTime.Parse("2012-02-20 17:09:39"), build.Created);
+ Assert.AreEqual("test.user", build.User);
}
}
}
View
1 Source/Hudson.Test/Tray/Presenters/BasePresenterTest.cs
@@ -5,6 +5,7 @@
namespace Hudson.Tray.Presenters
{
[TestFixture]
+ [Ignore]
public class BasePresenterTest
{
private FakePresenter presenter;
View
1 Source/Hudson.Test/Web/Controllers/ServerControllerTest.cs
@@ -6,6 +6,7 @@
namespace Hudson.Web.Controllers
{
[TestFixture]
+ [Ignore]
public class ServerControllerTest
{
private ServerController controller;
View
121 Source/Hudson.Test/Xml/BuildResponse.xml
@@ -1,38 +1,83 @@
-<freeStyleBuild>
- <action>
- <cause>
- <shortDescription>Started by user</shortDescription>
- </cause>
- </action>
- <action></action>
- <building>true</building>
- <duration>28204</duration>
- <fullDisplayName>first-job #92</fullDisplayName>
- <keepLog>false</keepLog>
- <number>92</number>
- <result>SUCCESS</result>
- <timestamp>1245606576953</timestamp>
- <url>http://www.example.com/job/first-job/92/</url>
- <builtOn></builtOn>
- <changeSet>
- <item>
- <date>2009-06-21</date>
- <msg>Changed account.</msg>
- <path>
- <editType>edit</editType>
- <file>/Source/File.cs</file>
- </path>
- <revision>119</revision>
- <user>user</user>
- </item>
- <kind>svn</kind>
- <revision>
- <module>svn://www.example.com/respository</module>
- <revision>119</revision>
- </revision>
- </changeSet>
- <culprit>
- <absoluteUrl>http://www.example.com/user/user</absoluteUrl>
- <fullName>user</fullName>
- </culprit>
-</freeStyleBuild>
+<freeStyleBuild>
+ <action>
+ <cause>
+ <shortDescription>Started by an SCM change</shortDescription>
+ </cause>
+ </action>
+ <action></action>
+ <action>
+ <buildsByBranchName>
+ <originmaster>
+ <buildNumber>1124</buildNumber>
+ <revision>
+ <SHA1>fa8825becade7adf64212e2395460d290e201d08</SHA1>
+ <branch>
+ <SHA1>fa8825becade7adf64212e2395460d290e201d08</SHA1>
+ <name>origin/HEAD</name>
+ </branch>
+ <branch>
+ <SHA1>fa8825becade7adf64212e2395460d290e201d08</SHA1>
+ <name>origin/master</name>
+ </branch>
+ </revision>
+ </originmaster>
+ </buildsByBranchName>
+ <lastBuiltRevision>
+ <SHA1>fa8825becade7adf64212e2395460d290e201d08</SHA1>
+ <branch>
+ <SHA1>fa8825becade7adf64212e2395460d290e201d08</SHA1>
+ <name>origin/HEAD</name>
+ </branch>
+ <branch>
+ <SHA1>fa8825becade7adf64212e2395460d290e201d08</SHA1>
+ <name>origin/master</name>
+ </branch>
+ </lastBuiltRevision>
+ <scmName></scmName>
+ </action>
+ <action></action>
+ <building>true</building>
+ <duration>811570</duration>
+ <fullDisplayName>first-job #92</fullDisplayName>
+ <id>2012-02-20_17-00-00</id>
+ <keepLog>false</keepLog>
+ <number>1124</number>
+ <result>SUCCESS</result>
+ <timestamp>1329757779000</timestamp>
+ <url>http://www.example.com/job/first-job/92/</url>
+ <builtOn></builtOn>
+ <changeSet>
+ <item>
+ <author>
+ <absoluteUrl>http://www.example.com:3333/user/test.other</absoluteUrl>
+ <fullName>test.other</fullName>
+ </author>
+ <comment>Ignore this.</comment>
+ <date>2012-02-20 17:00:00 +0000</date>
+ <id>d7da709252cbeff92c7992a4ca89908b6f68bbe1</id>
+ <msg>Ignore this.</msg>
+ <path>
+ <editType>edit</editType>
+ <file>Source/File.cs</file>
+ </path>
+ </item>
+ <item>
+ <author>
+ <absoluteUrl>http://www.example.com:3333/user/test.user</absoluteUrl>
+ <fullName>test.user</fullName>
+ </author>
+ <comment>Fixed stuff.</comment>
+ <date>2012-02-20 17:00:00 +0000</date>
+ <id>d7da709252cbeff92c7992a4ca89908b6f68bbe1</id>
+ <msg>Fixed stuff.</msg>
+ <path>
+ <editType>edit</editType>
+ <file>Source/File.cs</file>
+ </path>
+ </item>
+ </changeSet>
+ <culprit>
+ <absoluteUrl>http://www.example.com:3333/user/other.guy</absoluteUrl>
+ <fullName>other.guy</fullName>
+ </culprit>
+</freeStyleBuild>
View
54 Source/Hudson.Test/Xml/ServerResponse.xml
@@ -1,27 +1,27 @@
-<hudson>
- <description>&lt;center&gt;&lt;b&gt;Build Server&lt;/b&gt;&lt;/center&gt;</description>
- <job>
- <name>first-job</name>
- <url>http://www.example.com/job/first-job/</url>
- <color>disabled</color>
- </job>
- <job>
- <name>second-job</name>
- <url>http://www.example.com/job/second-job/</url>
- <color>blue</color>
- </job>
- <job>
- <name>third-job</name>
- <url>http://www.example.com/job/third-job/</url>
- <color>disabled</color>
- </job>
- <primaryView>
- <name>All</name>
- <url>http://www.example.com/</url>
- </primaryView>
- <slaveAgentPort>0</slaveAgentPort>
- <view>
- <name>All</name>
- <url>http://www.example.com/</url>
- </view>
-</hudson>
+<hudson>
+ <description>&lt;center&gt;&lt;b&gt;Build Server&lt;/b&gt;&lt;/center&gt;</description>
+ <job>
+ <name>first-job</name>
+ <url>http://www.example.com/job/first-job/</url>
+ <color>disabled</color>
+ </job>
+ <job>
+ <name>second-job</name>
+ <url>http://www.example.com/job/second-job/</url>
+ <color>blue</color>
+ </job>
+ <job>
+ <name>third-job</name>
+ <url>http://www.example.com/job/third-job/</url>
+ <color>disabled</color>
+ </job>
+ <primaryView>
+ <name>All</name>
+ <url>http://www.example.com/</url>
+ </primaryView>
+ <slaveAgentPort>0</slaveAgentPort>
+ <view>
+ <name>All</name>
+ <url>http://www.example.com/</url>
+ </view>
+</hudson>
View
2 Source/Hudson.Web/Models/BuildModel.cs
@@ -24,7 +24,7 @@ public class BuildModel
/// Gets or sets the revision.
/// </summary>
/// <value>The revision.</value>
- public int Revision { get; set; }
+ public string Revision { get; set; }
/// <summary>
/// Gets or sets the created.

0 comments on commit aa699ba

Please sign in to comment.