【问题标题】:Where do Xcode Bots put their results, so I can parse them?Xcode Bots 将它们的结果放在哪里,以便我可以解析它们?
【发布时间】:2014-04-20 14:13:00
【问题描述】:

我们的开发团队一直使用 Jenkins 进行 iOS 构建,并在构建(黄色)、成功(绿色)、失败(红色)时使用飞利浦 Hue 灯通知团队。

现在我们已经搬到Xcode CI and Bots,我不知道什么时候有单元测试失败了。我们甚至不知道构建阶段是否失败。

在 Xcode Bots CI 上,您可以获得这个“大屏幕”功能: 在 Apple 的 "Manage and Monitor Bots from a Web Browser" Docs 中,您可以看到它具有各种可以键控色调光的状态。

我真的不想破解某些东西并解析 HTML 页面。虽然很有趣,但如果 Apple 更新他们的 HTML 标记,这项工作不会持续很长时间。

当 Xcode 机器人完成集成时,是否会生成一个可解析的文件?

我很想显示色相:
* 蓝色表示分析警告
* 橙色表示构建警告
* 红色表示构建错误
* 黄色表示构建运行

【问题讨论】:

    标签: xcode philips-hue xcode-bots


    【解决方案1】:

    我想分享团队的解决方案。我们找到了存储 Bot 结果的位置,我们使用 bash 对其进行解析,并通过 curl 系统调用向 HUE 灯发送消息。我们在构建脚本前后调用方案中的脚本。

    我们在以下位置解析机器人的结果 plist:

    /Library/Server/Xcode/Data/BotRuns/Latest/output/xcodebuild_result.bundle/Info.plist

    在那里你可以找到各种很酷的数据来使用!:

    <dict>
        <key>AnalyzerWarningCount</key>
        <integer>0</integer>
        <key>AnalyzerWarningSummaries</key>
        <array/>
        <key>ErrorCount</key>
        <integer>0</integer>
        <key>ErrorSummaries</key>
        <array/>
        <key>LogIdentifier</key>
        <string>705bffcb-7453-49ba-882f-80e1218b59cf</string>
        <key>LogPath</key>
        <string>1_Test/action.xcactivitylog</string>
        <key>Status</key>
        <string>IDEActionResultStatus_Succeeded</string>
        <key>TestFailureSummaries</key>
        <array/>
        <key>TestSummaryIdentifier</key>
        <string>a1554874-4d40-4e94-ae89-a73184ec97a9</string>
        <key>TestSummaryPath</key>
        <string>1_Test/action_TestSummaries.plist</string>
        <key>TestsCount</key>
        <integer>185</integer>
        <key>TestsFailedCount</key>
        <integer>0</integer>
        <key>WarningCount</key>
        <integer>0</integer>
        <key>WarningSummaries</key>
        <array/>
    <dict>
    
    • AnalyzerWarningCount
    • 错误计数
    • 警告计数
    • TestsFailedCount

    哦 bash,我有时的情人,再来拯救一天。

    还要注意使用 Plist Buddy 来解析 Xcode 的 XML 属性列表文件。从 plist 文件中获取信息的首选。

        #!/bin/bash
        #
        #   By Phil
        #
        exec > /tmp/my_log_file.txt 2>&1
        TEST_RESULT_PLIST="/Library/Server/Xcode/Data/BotRuns/Latest/output/xcodebuild_result.bundle/Info.plist"
    
        hue_light_green=false
    
        echo "testResultParse_OwlHue"
    
        #If not bot, return
        if [ "$(whoami)" != "_teamsserver" ]; then
            echo "$(whoami) - Not a bot!";
            exit 1
        fi
    
        #1 If file not found ERROR
        if [ ! -f $TEST_RESULT_PLIST ]; then
            curl -X PUT -d "{\"on\":true,\"bri\":32,\"effect\":\"none\",\"hue\":150,\"sat\":255,\"alert\":\"lselect\"}" ipaddress/api/testestest/lights/3/state
            echo "Test Result Plist not Found";
            exit 1
        fi
    
        #2 AnalyzerWarningCount BLUE
        AnalyzerWarningCount=$(/usr/libexec/PlistBuddy -c "Print :AnalyzerWarningCount" "${TEST_RESULT_PLIST}")
        if [ $AnalyzerWarningCount != 0 ]; then
            echo "AnalyzerWarningCount";
            curl -X PUT -d "{\"on\":true,\"bri\":32,\"xy\":[0.16, 0.1],\"hue\":15815,\"sat\":255,\"effect\":\"none\",\"alert\":\"lselect\"}" ipaddress/api/testestest/lights/3/state
        fi
    
        #3 WarningCount
        WarningCount=$(/usr/libexec/PlistBuddy -c "Print :WarningCount" "${TEST_RESULT_PLIST}")
        if [ $WarningCount != 0 ]; then
            curl -X PUT -d "{\"on\":true,\"bri\":32,\"xy\":[0.58, 0.41],\"hue\":15815,\"sat\":255,\"effect\":\"none\",\"alert\":\"lselect\"}" ipaddress/api/testestest/lights/3/state
            echo "WarningCount";
        fi
    
        #4 ErrorCount || TestsFailedCount ERROR
        ErrorCount=$(/usr/libexec/PlistBuddy -c "Print :ErrorCount" "${TEST_RESULT_PLIST}")
        if [ $ErrorCount != 0 ]; then
            curl -X PUT -d "{\"on\":true,\"bri\":32,\"effect\":\"none\",\"hue\":150,\"sat\":255,\"alert\":\"lselect\"}" ipaddress/api/testestest/lights/3/state
            echo "ErrorCount";
            exit 1
        fi
    
        #5 TestsFailedCount ERROR
        ErrorCount=$(/usr/libexec/PlistBuddy -c "Print :ErrorCount" "${TEST_RESULT_PLIST}")
        if [ $TestsFailedCount != 0 ]; then
            curl -X PUT -d "{\"on\":true,\"bri\":32,\"effect\":\"none\",\"hue\":150,\"sat\":255,\"alert\":\"lselect\"}" ipaddress/api/testestest/lights/3/state
            echo "TestsFailedCount";
            exit 1
        fi
    
        #6 None of the above.  SUCCESS
        if [ "$hue_light_green" = true ] ; then
            echo "SUCCESS";
            curl -X PUT -d "{\"on\":true,\"bri\":32,\"effect\":\"none\",\"hue\":25500,\"sat\":255,\"alert\":\"lselect\"}" ipaddress/api/testestest/lights/3/state
        fi
    
    • AnalyzerWarningCount 蓝色
    • 错误计数红色
    • WarningCount 橙色
    • TestsFailedCount 红色

    现在,当我们对上述任何一项进行计数时,我们会看到闪烁的颜色变化。例如,下面的代码会从我们的色调中产生明亮的蓝色:

    【讨论】:

    • 在 OS X 10.10 Yosemite 中结果 plist 文件的位置是否已更改?我什至在 /Library/Server/Xcode 上都没有文件夹。
    • 服务器已移至/Library/Developer/XcodeServer/,但我没有看到类似BotRuns/Latest 的内容...
    【解决方案2】:

    OS X Server 4.0 的结果路径似乎是:

    /Library/Developer/XcodeServer/IntegrationAssets/Your_Bot/

    • Archive.xcarchive.zip
    • build.log
    • buildService.log
    • Your_Bot.ipa
    • sourceControl.log
    • xcodebuild_result.bundle.zip

    xcodebuild_result.bundle 现在是一个 zip 文件,我从 buildService.log 解析构建结果:

    Build results summary: {
    analyzerWarningChange = 14;
    analyzerWarningCount = 14;
    errorChange = 0;
    errorCount = 0;
    improvedPerfTestCount = 0;
    regressedPerfTestCount = 0;
    testFailureChange = 0;
    testFailureCount = 0;
    testsChange = 0;
    testsCount = 0;
    warningChange = 20;
    warningCount = 20;
    }
    

    【讨论】:

    • 为我工作,谢谢。您知道在哪里可以找到每个测试的详细输出吗?
    【解决方案3】:

    对于在此处查看这些答案的任何人来说,对 buildService.log 文件的抓取是不必要的(实际上什至不会工作,因为相对于运行触发器而言,何时创建日志的鸡/蛋问题)。尝试在 Trigger Script 中运行命令env,您会看到 Xcode 实际上会根据测试结果设置环境变量,其中一些比较值得注意的是:

    XCS_BOT_NAME=My New Bot
    XCS_WARNING_CHANGE=0
    XCS_INTEGRATION_RESULT=succeeded
    XCS_TEST_FAILURE_COUNT=0
    XCS_TEST_FAILURE_CHANGE=0
    XCS_ERROR_COUNT=0
    XCS_ANALYZER_WARNING_COUNT=0
    XCS_TESTS_CHANGE=0
    XPC_SERVICE_NAME=0
    XCS_ERROR_CHANGE=0
    XCS_WARNING_COUNT=0
    XCS_TESTS_COUNT=3
    XCS_INTEGRATION_NUMBER=1
    

    【讨论】:

      最近更新 更多