海鸥航迹

学习之笔记,好文之收集。

导航

CruiseControl.NET svnRevsionLabel故障解决

环境:

CruiseControl.NET 1.4

SVN Revision Labeller 1.0.3

异常信息:

Error Message:
System.Xml.XmlException: 行 7 上的开始标记“msg”与结束标记“logentry”不匹配。 行 8,位置 3。 在 System.Xml.XmlTextReaderImpl.Throw(Exception e) 在 System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) 在 System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) 在 System.Xml.XmlTextReaderImpl.ParseEndElement() 在 System.Xml.XmlTextReaderImpl.ParseElementContent() 在 System.Xml.XmlTextReaderImpl.Read() 在 System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) 在 System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) 在 System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) 在 System.Xml.XmlDocument.Load(XmlReader reader) 在 System.Xml.XmlDocument.LoadXml(String xml) 在 ccnet.SvnRevisionLabeller.plugin.SvnRevisionLabeller.GetRevision() 在 ccnet.SvnRevisionLabeller.plugin.SvnRevisionLabeller.Generate(IIntegrationResult resultFromLastBuild) 在 ThoughtWorks.CruiseControl.Core.Project.CreateLabel(IIntegrationResult result) 在 ThoughtWorks.CruiseControl.Core.IntegrationRunner.Integrate(IntegrationRequest request)

异常出现频率:

当svn log中有非英文字符时(中文,日文,韩文...)时,必现。

故障原因:

SVN Revision Labeller 读取svn输出时,使用的是系统默认的编码流,而svn默认的输出为UTF-8.

解决办法:

修改SVN Revision Labeller 1.0.3项目的GetRevision函数如下:

private int GetRevision()
        {
            // Set up the command-line arguments required
            ProcessArgumentBuilder argBuilder = new ProcessArgumentBuilder();
            argBuilder.AppendArgument("log");
            argBuilder.AppendArgument("--xml");
            argBuilder.AppendArgument("--limit 1");
            argBuilder.AppendArgument(Url);
            if (Username != null && Username.Length > 0 && Password != null && Password.Length > 0)
            {
                AppendCommonSwitches(argBuilder);
            }

            ProcessStartInfo info = new ProcessStartInfo ();
            info.FileName = executable;
            info.Arguments = argBuilder.ToString();
            info.RedirectStandardOutput = true;
            info.UseShellExecute = false;
            info.CreateNoWindow = true;
            Process p = new Process();
            p.StartInfo = info;
            p.Start();
            string output;
            using (StreamReader r = new StreamReader(p.StandardOutput.BaseStream, Encoding.UTF8))
            {
                output = r.ReadToEnd();
            }
            p.WaitForExit();

            // Run the svn log command and capture the results
            //ProcessResult result = RunProcess(argBuilder);             
            //Log.Debug("Received XML : " + result.StandardOutput);
            Log.Debug("Received XML : " + output);

            // Load the results into an XML document
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(output);

            // Retrieve the revision number from the XML
            XmlNode node = xml.SelectSingleNode(RevisionXPath);
            return Convert.ToInt32(node.InnerText);
        }

重新编译SVN Revision Labeller 1.0.3,应用到服务器上,问题解决。

编译好的文件请下载ccnet.SvnRevisionLabeller.plugin.dll

posted on 2009-03-31 13:08  海天一鸥  阅读(1338)  评论(1编辑  收藏  举报