我在Jenkins Pipeline中有这样的阶段定义:
stage('iPhone 8, iOS 11.4') {
steps {
sh 'echo "Unit Tests for iPhone 8, iOS 11.4"'
sh 'xcodebuild -scheme "[SCHEME]" -workspace [PROJECT].xcworkspace -configuration "Debug" test-without-building -destination "platform=iOS Simulator,name=iPhone 8,OS=11.4" -enableCodeCoverage YES | /usr/local/bin/xcpretty -r junit --output ./build/reports/junit-11.4.xml'
}
post {
failure {
sh 'echo "${env.STAGE_NAME} failed"'
notifyUnstableSlack(env.STAGE_NAME)
}
}
}
...
def notifyUnstableSlack(String stageName) {
stageName = stageName ?: ''
def color = '#FFFE89'
def msg = "UNSTABLE: `${env.JOB_NAME}@${stageName}` #${env.BUILD_NUMBER}:\n${env.BUILD_URL}"
slackSend(color: color, message: msg)
}
当此阶段的测试失败并且阶段状态为FAILED / UNSTABLE但未发送任何内容时,我尝试发送Slack通知。
我还尝试了unstable{}
块中的post{}
动作,但这也没有向松弛发送任何消息。
更新: 阶段结束日志:
Executed 52 tests, with 1 failure (0 unexpected) in 0.155 (0.162) seconds
2019-04-07 11:11:04.708 xcodebuild[8728:129932] IDETestOperationsObserverDebug: Failure collecting logarchive: Test daemon protocol version 22 is too old to support log archive collection (minimum 26)
2019-04-07 11:11:04.710 xcodebuild[8728:124814] [MT] IDETestOperationsObserverDebug: 65.073 elapsed -- Testing started completed.
2019-04-07 11:11:04.710 xcodebuild[8728:124814] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2019-04-07 11:11:04.710 xcodebuild[8728:124814] [MT] IDETestOperationsObserverDebug: 65.073 sec, +65.073 sec -- end
Failing tests:
ProjectTests:
ViewControllerTests.test_Geocoder_FetchesCoordinates()
Test session results and logs:
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/Project-eicgdkjbrvpuddesfbyzlxovkhgp/Logs/Test/Test-Project-2019.04.07_11-09-59-+0200.xcresult
** TEST EXECUTE FAILED **