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

时间:2014-03-15 04:04:08

标签: xcode philips-hue xcode-bots

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

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

在Xcode Bots CI上你得到了这个" bigscreen"特征: 在Apple的"Manage and Monitor Bots from a Web Browser" Docs中,您可以看到它有各种各样的状态可以锁定色调。

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

Xcode机器人完成集成时是否有可解析的文件?

我喜欢让Hue表现出来:
* Blue for Analysis警告
*橙色用于构建警告
*红色表示构建错误
*黄色用于构建运行

3 个答案:

答案 0 :(得分: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>
  • 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
  • AnalyzerWarningCount 蓝色
  • ErrorCount 红色
  • WarningCount 橙色
  • TestsFailedCount 红色

现在,当我们得到上述任何一项的计数时,我们会得到一个闪烁的颜色变化。例如,以下颜色从我们的色调产生亮蓝色: enter image description here

答案 1 :(得分:4)

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

<强> /库/开发商/ 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;
}

答案 2 :(得分:4)

对于那些在这些答案之后看到这里的人来说,抓取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