Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
887 views
in Technique[技术] by (71.8m points)

dart - GitLab Flutter CI fails with "tojunit: command not found"

I'm using the following .gitlab-ci.yml file to run tests using junit and export the report as an XML artifact:

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

The application has the following package dependencies:

dependencies:
  flutter:
    sdk: flutter
  junitreport: ^1.3.1

When this pipeline is ran, I get the following error:

$ 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)

I'm trying to figure out why this is failing. The command should be found since the package is retrieved in before_script stanza before the analyze-and-test is called. What am I missing?

question from:https://stackoverflow.com/questions/66046443/gitlab-flutter-ci-fails-with-tojunit-command-not-found

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Looks like tojunit is not installed on CI machine. According to junitreport installation instruction you should run this command to download the program and make a launch script available:

pub global activate junitreport

So firstly add this command to before_script phase:

before_script:
 - flutter pub get
 - flutter clean
 - flutter --version
 - flutter pub global activate junitreport

Try to run this.

Next, if the {dart-cache}/bin directory is not on your path, you will get a warning, including tips on how to fix it. In that case you will need to add some more commands (from tips) to before_script.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...