我使用以下.gitlab-ci.yml
文件使用junit
运行测试,并将报告导出为XML工件:
image: cirrusci/flutter:stable
before_script:
- flutter pub get
- flutter clean
- flutter --version
stages:
- analyze-and-test
analyze-and-test:
stage: analyze-and-test
script:
- flutter build aot
- flutter analyze
# - flutter test
- flutter test --machine | tojunit -o report.xml
artifacts:
when: always
reports:
junit:
- report.xml
only:
- master
- merge_requests
应用程序有以下包依赖项:
dependencies:
flutter:
sdk: flutter
junitreport: ^1.3.1
当这个管道运行时,我得到以下错误:
$ flutter test --machine | tojunit -o report.xml
/usr/bin/bash: line 139: tojunit: command not found
Unhandled exception:
FileSystemException: writeFrom failed, path = '' (OS Error: Broken pipe, errno = 32)
我想知道为什么这是失败的。该命令应该被找到,因为在调用analyze-and-test
之前,包是在before_script
节中检索的。我错过了什么?
看起来tojunit没有安装在CI机上。根据junitreport安装说明,您应该运行以下命令来下载程序并提供启动脚本:
pub global activate junitreport
所以首先将这个命令添加到before_script
阶段:
before_script:
- flutter pub get
- flutter clean
- flutter --version
- flutter pub global activate junitreport
试着运行这个。
接下来,如果{dart-cache}/bin
目录不在您的路径上,您将得到一个警告,包括如何修复它的提示。在这种情况下,您将需要向before_script
添加一些命令(来自提示)。