Jenkins 因未捕获异常而失败:*** -[_NSStdIOFileHandle writeData:]: Broken pipe
Jenkins fails with Uncaught Exception: *** -[_NSStdIOFileHandle writeData:]: Broken pipe
我正在尝试使用 Jenkins 为我的 iOS 项目(Xcode 10.2.1)进行 CICD 设置。
我正在使用 Fastlane 为测试、归档等创建通道
除测试车道外,所有车道都运行良好。如果我直接使用终端执行通道,则不会记录任何问题。它工作得很好。请在下面找到测试通道
desc "run tests"
lane :executetest do
begin
# Something where you'd like to be able to react to failures
scan(scheme: "iOSProjectTests")
# If ANY exception happens, let me handle it
rescue => ex
# re-raise the exception unless it's something we're OK with ignoring
# raise ex unless ex.message.include?('Error message of interest')
# UI.error ex
# UI.user_error!("Lint check or Test case failed, but continuing anyway!")
UI.important("There were a few failing test cases. Continuing execution")
end
end
但是在 jenkins 中,一旦测试通道开始,我就会遇到异常并且构建失败,
** INTERNAL ERROR: Uncaught exception while building **
[18:09:51]: ▸ Uncaught Exception: *** -[_NSStdIOFileHandle writeData:]: Broken pipe
[18:09:51]: ▸ Stack:
[18:09:52]: ▸ 0 __exceptionPreprocess (in CoreFoundation)
[18:09:52]: ▸ 1 objc_exception_throw (in libobjc.A.dylib)
[18:09:52]: ▸ 2 +[NSException raise:format:] (in CoreFoundation)
[18:09:52]: ▸ 3 -[NSConcreteFileHandle writeData:] (in Foundation)
[18:09:52]: ▸ 4 IDETestingFileHandleOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 5 @objc IDETestingFileHandleOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 6 specialized IDETestingMultiOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 7 @objc IDETestingFileHandleOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 8 specialized IDETestingLaunchSession.parseConsoleOutput(fromOriginalOutput:) (in IDEFoundation)
[18:09:52]: ▸ 9 @objc IDETestingLaunchSession.parseConsoleOutput(fromOriginalOutput:) (in IDEFoundation)
[18:09:52]: ▸ 10 -[IDEConsoleAdaptor _delegateProcessedOutput:] (in IDEFoundation)
[18:09:52]: ▸ 11 -[IDEConsoleAdaptor _getData:fileHandle:overflowBuffer:stringBuffer:] (in IDEFoundation)
[18:09:52]: ▸ 12 -[IDEConsoleAdaptor _getDataFromNotification:overflowBuffer:stringBuffer:] (in IDEFoundation)
[18:09:52]: ▸ 13 -[IDEConsoleAdaptor _getOutputFromNotification:] (in IDEFoundation)
[18:09:52]: ▸ 14 DVTInvokeWithLazyFailureHint (in DVTFoundation)
[18:09:52]: ▸ 15 -[_DVTNotificationReceiver receiveNotification:] (in DVTFoundation)
[18:09:52]: ▸ 16 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
[18:09:52]: ▸ 17 ___CFXRegistrationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 18 _CFXRegistrationPost (in CoreFoundation)
[18:09:52]: ▸ 19 ___CFXNotificationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 20 -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
[18:09:52]: ▸ 21 _CFXNotificationPost (in CoreFoundation)
[18:09:52]: ▸ 22 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
[18:09:52]: ▸ 23 -[IDEMasterPtyFileHandle _gotData:] (in IDEFoundation)
[18:09:52]: ▸ 24 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
[18:09:52]: ▸ 25 ___CFXRegistrationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 26 _CFXRegistrationPost (in CoreFoundation)
[18:09:52]: ▸ 27 ___CFXNotificationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 28 -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
[18:09:52]: ▸ 29 _CFXNotificationPost (in CoreFoundation)
[18:09:52]: ▸ 30 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
[18:09:52]: ▸ 31 _performFileHandleSource (in Foundation)
[18:09:52]: ▸ 32 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (in CoreFoundation)
[18:09:52]: ▸ 33 __CFRunLoopDoSource0 (in CoreFoundation)
[18:09:52]: ▸ 34 __CFRunLoopDoSources0 (in CoreFoundation)
[18:09:52]: ▸ 35 __CFRunLoopRun (in CoreFoundation)
[18:09:52]: ▸ 36 CFRunLoopRunSpecific (in CoreFoundation)
[18:09:52]: ▸ 37 CFRunLoopRun (in CoreFoundation)
[18:09:52]: ▸ 38 -[Xcode3CommandLineBuildTool _buildWithTimingSection:] (in Xcode3Core)
[18:09:52]: ▸ 39 -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
[18:09:52]: ▸ 40 main (in xcodebuild)
[18:09:52]: ▸ 41 start (in libdyld.dylib)
无法在任何地方获得有关此的任何帮助。项目中只有默认编写的 XCTest 用例。它甚至不是一个真正的测试用例。
我把快车道改到下面
desc "run tests"
lane :executetest do
begin
# Something where you'd like to be able to react to failures
scan(
scheme: "iOSProjectTests",
devices: ["iPhone X"],
output_style: "standard")
# If ANY exception happens, let me handle it
rescue => ex
# re-raise the exception unless it's something we're OK with ignoring
# raise ex unless ex.message.include?('Error message of interest')
# UI.error ex
# UI.user_error!("Lint check or Test case failed, but continuing anyway!")
UI.important("There were a few failing test cases. Continuing execution")
end
end
我正在使用 Homebrew 运行 jenkins。而是使用 Jenkins-lts
来启动詹金斯。这解决了上述问题。
我正在尝试使用 Jenkins 为我的 iOS 项目(Xcode 10.2.1)进行 CICD 设置。 我正在使用 Fastlane 为测试、归档等创建通道
除测试车道外,所有车道都运行良好。如果我直接使用终端执行通道,则不会记录任何问题。它工作得很好。请在下面找到测试通道
desc "run tests"
lane :executetest do
begin
# Something where you'd like to be able to react to failures
scan(scheme: "iOSProjectTests")
# If ANY exception happens, let me handle it
rescue => ex
# re-raise the exception unless it's something we're OK with ignoring
# raise ex unless ex.message.include?('Error message of interest')
# UI.error ex
# UI.user_error!("Lint check or Test case failed, but continuing anyway!")
UI.important("There were a few failing test cases. Continuing execution")
end
end
但是在 jenkins 中,一旦测试通道开始,我就会遇到异常并且构建失败,
** INTERNAL ERROR: Uncaught exception while building **
[18:09:51]: ▸ Uncaught Exception: *** -[_NSStdIOFileHandle writeData:]: Broken pipe
[18:09:51]: ▸ Stack:
[18:09:52]: ▸ 0 __exceptionPreprocess (in CoreFoundation)
[18:09:52]: ▸ 1 objc_exception_throw (in libobjc.A.dylib)
[18:09:52]: ▸ 2 +[NSException raise:format:] (in CoreFoundation)
[18:09:52]: ▸ 3 -[NSConcreteFileHandle writeData:] (in Foundation)
[18:09:52]: ▸ 4 IDETestingFileHandleOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 5 @objc IDETestingFileHandleOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 6 specialized IDETestingMultiOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 7 @objc IDETestingFileHandleOutputStream.write(_:) (in IDEFoundation)
[18:09:52]: ▸ 8 specialized IDETestingLaunchSession.parseConsoleOutput(fromOriginalOutput:) (in IDEFoundation)
[18:09:52]: ▸ 9 @objc IDETestingLaunchSession.parseConsoleOutput(fromOriginalOutput:) (in IDEFoundation)
[18:09:52]: ▸ 10 -[IDEConsoleAdaptor _delegateProcessedOutput:] (in IDEFoundation)
[18:09:52]: ▸ 11 -[IDEConsoleAdaptor _getData:fileHandle:overflowBuffer:stringBuffer:] (in IDEFoundation)
[18:09:52]: ▸ 12 -[IDEConsoleAdaptor _getDataFromNotification:overflowBuffer:stringBuffer:] (in IDEFoundation)
[18:09:52]: ▸ 13 -[IDEConsoleAdaptor _getOutputFromNotification:] (in IDEFoundation)
[18:09:52]: ▸ 14 DVTInvokeWithLazyFailureHint (in DVTFoundation)
[18:09:52]: ▸ 15 -[_DVTNotificationReceiver receiveNotification:] (in DVTFoundation)
[18:09:52]: ▸ 16 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
[18:09:52]: ▸ 17 ___CFXRegistrationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 18 _CFXRegistrationPost (in CoreFoundation)
[18:09:52]: ▸ 19 ___CFXNotificationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 20 -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
[18:09:52]: ▸ 21 _CFXNotificationPost (in CoreFoundation)
[18:09:52]: ▸ 22 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
[18:09:52]: ▸ 23 -[IDEMasterPtyFileHandle _gotData:] (in IDEFoundation)
[18:09:52]: ▸ 24 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
[18:09:52]: ▸ 25 ___CFXRegistrationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 26 _CFXRegistrationPost (in CoreFoundation)
[18:09:52]: ▸ 27 ___CFXNotificationPost_block_invoke (in CoreFoundation)
[18:09:52]: ▸ 28 -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
[18:09:52]: ▸ 29 _CFXNotificationPost (in CoreFoundation)
[18:09:52]: ▸ 30 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
[18:09:52]: ▸ 31 _performFileHandleSource (in Foundation)
[18:09:52]: ▸ 32 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (in CoreFoundation)
[18:09:52]: ▸ 33 __CFRunLoopDoSource0 (in CoreFoundation)
[18:09:52]: ▸ 34 __CFRunLoopDoSources0 (in CoreFoundation)
[18:09:52]: ▸ 35 __CFRunLoopRun (in CoreFoundation)
[18:09:52]: ▸ 36 CFRunLoopRunSpecific (in CoreFoundation)
[18:09:52]: ▸ 37 CFRunLoopRun (in CoreFoundation)
[18:09:52]: ▸ 38 -[Xcode3CommandLineBuildTool _buildWithTimingSection:] (in Xcode3Core)
[18:09:52]: ▸ 39 -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
[18:09:52]: ▸ 40 main (in xcodebuild)
[18:09:52]: ▸ 41 start (in libdyld.dylib)
无法在任何地方获得有关此的任何帮助。项目中只有默认编写的 XCTest 用例。它甚至不是一个真正的测试用例。
我把快车道改到下面
desc "run tests"
lane :executetest do
begin
# Something where you'd like to be able to react to failures
scan(
scheme: "iOSProjectTests",
devices: ["iPhone X"],
output_style: "standard")
# If ANY exception happens, let me handle it
rescue => ex
# re-raise the exception unless it's something we're OK with ignoring
# raise ex unless ex.message.include?('Error message of interest')
# UI.error ex
# UI.user_error!("Lint check or Test case failed, but continuing anyway!")
UI.important("There were a few failing test cases. Continuing execution")
end
end
我正在使用 Homebrew 运行 jenkins。而是使用 Jenkins-lts
来启动詹金斯。这解决了上述问题。