簡體   English   中英

自定義工作流程活動-從構建詳細信息中獲取警告

[英]Custom Workflow Activity - Get Warnings from Build Details

好的,這是東西:

我很生氣,試圖在調用CustomActivity時從IBuildDetail對象獲取警告。

這是我嘗試過的:

private static List<IBuildInformationNode> GetBuildWarnings(IBuildDetail buildInformation)
{
    var warnings = buildInformation.Information.GetNodesByType(InformationTypes.BuildWarning);

    if (warnings.Count == 0 && buildInformation.CompilationStatus == BuildPhaseStatus.Succeeded)
    {
        buildInformation.RefreshAllDetails();
        warnings = buildInformation.Information.GetNodesByType(InformationTypes.BuildWarning);
    }
    return warnings;
}

這給了我0警告

我也嘗試過使用相同的代碼:

var warnings = InformationNodeConverters.GetBuildWarnings(buildInformation);

仍然沒有警告。

這個CustomActivity在工作流的結尾被調用:實際上,檢索其余的細節(例如構建狀態,構建錯誤,測試信息等)沒有任何問題。

問題僅在於警告

有趣的是,在構建結束時,當我檢查構建結果時, 會有ARE警告

有任何想法嗎?

提前致謝!

運行自定義活動是否可能發生警告。 您可以檢查構建日志並准確查看警告發生的位置嗎?

buildDetail.Information.GetNodesByType(InformationTypes.BuildWarning)不會返回您要查找的內容,因為來自跟蹤參與者的消息不會立即刷新。

InformationNodeConverters.GetBuildWarnings在內部調用GetNodesByType(),因此由於相同的原因它將無法正常工作。

原始信息保存在TrackingParticipant的內部字段中,因此無法訪問。 無論如何,如果您等待> 15秒,則來自此內部字段的信息將刷新到可訪問字段。

因此,完成這項工作的丑陋駭客似乎是:

System.Threading.Thread.Sleep(16000);
var trackingParticipant = context.GetExtension<Microsoft.TeamFoundation.Build.Workflow.Tracking.BuildTrackingParticipant>();
var warnings = GetWarnings(trackingParticipant.GetActivityTracking(context));


    private List<IBuildInformationNode> GetWarnings(IActivityTracking activityTracking ){
        IBuildInformationNode rootNode = getRootNode( activityTracking.Node );
        return rootNode.Children.GetNodesByType(InformationTypes.BuildWarning, true);
    }

    private IBuildInformationNode getRootNode( IBuildInformationNode  node)
    {
        while( node.Parent != null ) node = node.Parent;
        return node;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM