CC.net 仪表板中未显示发送电子邮件的例外情况

Exception of sending email doesn't show in the CC.net Dashboard

所有,我在 ccnet.config 中成功配置了电子邮件发布者。它工作正常。构建、单元测试、合并结果等所有任务均已成功完成。 但出于某种原因。我弄错了 smtp 身份验证用户名,这将在 运行 构建时导致异常。顺便一提。我设置的通知是始终。

        <publishers>
            <statistics />
            <merge>
                <files>
                    <file>TestResult\UnitTestResults.trx</file>
                </files>
            </merge>

            <buildpublisher>
                <sourceDir>E:\study\cc.net\Test\KMIH\BackUpFolder\Source</sourceDir>
                <publishDir>E:\study\cc.net\Test\KMIH\BackUpFolder\Publish</publishDir>
                <useLabelSubDirectory>true</useLabelSubDirectory>
                <alwaysPublish>true</alwaysPublish>
            </buildpublisher>
            <email mailport="25" mailhostUsername="xxxxxx" mailhostPassword="xxxxxx" useSSL="FALSE" includeDetails="true">
                <from>xxxxx@163.com</from>
                <mailhost>smtp.163.com</mailhost>
                <users>
                    <user name="JoeWang" group="BuildMaster" address="xxxxx@163.com"/>
                </users>
                <groups>
                    <group name="BuildMaster">
                        <notifications>
                            <notificationType>Always</notificationType>
                        </notifications>
                    </group>
                </groups>
            </email>
            <xmllogger/>
            <artifactcleanup cleanUpMethod="KeepLastXBuilds" cleanUpValue="50"/>
        </publishers>

所以希望我希望在检查 Dashboard 的构建报告时看到这个错误。我可以看到失败的构建。但是我没有发现任何错误消息或信息让我知道到底是什么错误。 (在这种情况下。这是错误的电子邮件配置)。

我是不是漏掉了什么?谢谢

查看源代码后。 (1.8.5.0) 。我想我找到原因了..

这似乎是一个 CC.net 错误。希望不是。

这是来自 ThoughtWorks.CruiseControl.Core.Tasks.TaskBase 的异常。

public virtual void Run(IIntegrationResult result)
        {
            // Initialise the task
            this.WasSuccessful = false;
            if ((this.currentStatus == null) ||
                (this.currentStatus.Status != ItemBuildStatus.Running))
            {
                InitialiseStatus(ItemBuildStatus.Pending);
                currentStatus.Status = ItemBuildStatus.Running;
            }

            // Perform the actual run
            currentStatus.TimeOfEstimatedCompletion = CalculateEstimatedTime();
            currentStatus.TimeStarted = DateTime.Now;
            try
            {
                this.WasSuccessful = Execute(result);//Email sending exception is threw out...
            }
            catch (Exception error)
            {
                // Store the error message
                currentStatus.Error = error.Message;
                result.Status = IntegrationStatus.Exception;
                throw;
            }
            finally
            {
                // Clean up
                currentStatus.Status = (this.WasSuccessful) ? ItemBuildStatus.CompletedSuccess : ItemBuildStatus.CompletedFailed;
                currentStatus.TimeCompleted = DateTime.Now;

                switch (result.Status)
                {
                    case IntegrationStatus.Unknown:
                    case IntegrationStatus.Success:
                        result.Status = this.WasSuccessful ? IntegrationStatus.Success : IntegrationStatus.Failure;
                        break;
                }
            }
        }

Execute 是一个抽象函数。

protected abstract bool Execute(IIntegrationResult result);

并且构建日志是在ClassXmlIntegrationResultWriter

中构建的
public void Write(IIntegrationResult result)
        {
            writer.WriteStartElement(Elements.CRUISE_ROOT);
            writer.WriteAttributeString("project", result.ProjectName);
            WriteRequest(result.IntegrationRequest);
            WriteModifications(result.Modifications);
            WriteIntegrationProperties(result);
            WriteBuildElement(result);
            WriteException(result);//since no exception found . so the log no exception detail populated. That is the root cause.
            writer.WriteEndElement();
        }

所以我认为异常应该在发生时添加到 IIntegrationResult 中,如下所示。

try
            {
                this.WasSuccessful = Execute(result);
            }
            catch (Exception error)
            {
                // Store the error message
                result.ExceptionResult = error;//Add the exception in the build process so that it will be generated in the build log. 
                currentStatus.Error = error.Message;
                result.Status = IntegrationStatus.Exception;
                throw;
            }

我用新编译的替换了 ccnet.exe。然后异常会显示在Dashboard的构建报告中。

有更好的主意吗?谢谢。