在 gitlab 的管道 运行 期间有时会出现错误 "flutter: command not found"

Sometimes get error "flutter: command not found" during pipeline run in gitlab

我们有一台带有 Runner for gitlab CI 的 macbook。 有时,管道会因错误 "flutter: command not found" 而失败。有时它工作正常并且所有单元和集成测试都通过。

造成这种行为的原因是什么?

gitlab-ci.yml 文件为:

before_script:
- flutter channel stable
- flutter upgrade
- flutter pub get

stages:
- test_unit
- test_integration

test_unit:
stage: test_unit
script:
  - flutter test
  - cd android
  - cp ~/builds/QKu8Lg6_/0/mobile/local.properties ~/builds/QKu8Lg6_/0/mobile/app/android
  - ./gradlew app:connectedAndroidTest
only:
  - merge_requests
except:
  - schedules
retry: 2


test_integration:
stage: test_integration
script:
  - flutter drive --target=test_driver/app/app.dart
  - flutter drive --target=test_driver/app/app.dart -d iPhone Xʀ
  - flutter drive --target=test_driver/skill/time/time.dart
  - flutter drive --target=test_driver/skill/time/time.dart -d iPhone Xʀ
only:
  - schedules
retry: 2

我们解决了!

问题出在默认的 gitlab runner 中,它适用于所有 gitlab 项目。 因此,我们有 2 个运行器:默认运行器和 macbook 的运行器。 有时,gitlab 在未配置的默认运行器上运行我们的构建并且失败。

我们从我们的 gitlab 项目中删除了默认运行器,一切都按预期工作!