チームのソリューションを共有したいと思います。ボットの結果が保存されている場所を見つけ、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
ああ、私の時々の恋人よ、もう一度助けに来てください。
また、Xcode の XML プロパティ リスト ファイルを解析するために Plist Buddy を使用していることにも注意してください。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青
- エラーカウント赤
- 警告カウントオレンジ
- TestsFailedCount赤
上記のいずれかのカウントを取得すると、点滅する色が変化します。たとえば、次の例では、色相から明るい青が生成されます。
