Xcode Bots在哪里放置他们的结果,所以我可以解析它们?

Sch*_*ank 4 xcode philips-hue xcode-bots

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

现在我们已经转移到Xcode CI和Bots,我不知道任何单元测试何时失败.我们甚至不知道构建阶段是否失败.

在Xcode Bots CI上,您可以获得这个"大屏幕"功能:在Apple的"从Web浏览器管理和监视机器人"文档中,您可以看到它具有可以键入色调光的各种状态.

我真的不想破解一些东西并解析HTML页面.尽管有趣,但如果Apple更新其HTML标记,这项工作将持续很长时间.

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

我很想让Hue显示:
*Blue for Analysis警告
*Orange表示构建警告
*Red表示构建错误
*黄色表示构建运行

Sch*_*ank 6

我想分享团队的解决方案.我们找到了存储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>
Run Code Online (Sandbox Code Playgroud)
  • AnalyzerWarningCount
  • 的ErrorCount
  • WARNINGCOUNT
  • TestsFailedCount

哦,我有时候的情人,再次来拯救这一天.

还要注意使用Plist Buddy来解析Xcode的XML属性列表文件.用于获取plist文件内外信息的primo选项.

    #!/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
Run Code Online (Sandbox Code Playgroud)
  • AnalyzerWarningCount 蓝色
  • ErrorCount 红色
  • WarningCount 橙色
  • TestsFailedCount 红色

现在,当我们得到上述任何一个的计数时,我们得到一个闪烁的颜色变化.例如,以下颜色从我们的色调产生亮蓝色: 在此输入图像描述