I run CI in GitLab, for this I made Runner on my local Windows 11 machine. The git, flutter and dart commands work on the local machine, but in GitLab CI/CD, which is executed on the same local machine, dart and flutter stop seeing git, although git commands are also executed.
Here is the output of the Job execution result:
Running with gitlab-runner 17.8.3 (690ce25c)
on Runner for rtk_app r6XCV3Lq, system ID: s_3713dd97b551
Preparing the "shell" executor
00:00
Using Shell (pwsh) executor...
Preparing environment
00:00
Running on KOMPUTER...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Work/GitLabRunner/builds/r6XCV3Lq/0/rostelecom_remote/flutterapplication/.git/
Checking out 2ffede7a as detached HEAD (ref is refs/merge-requests/51/head)...
git-lfs/3.6.1 (GitHub; windows amd64; go 1.23.3; git ea47a34b)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ git status
HEAD detached at 2ffede7a
nothing to commit, working tree clean
$ flutter pub get
Error: Unable to find git in your PATH.
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
The same actions are freely performed in the terminal:
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.27.2, on Microsoft Windows [Version 10.0.22631.4602], locale ru-RU)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4)
[√] Android Studio (version 2024.2)
[√] VS Code (version 1.96.4)
[√] Connected device (1 available)
[√] Network resources
! Doctor found issues in 1 category.
Here is runner config:
token_obtained_at = 2025-02-08T11:10:12Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "shell"
shell = "pwsh"
[runners.custom_build_dir]
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
And gitlab-ci file:
stages:
- static
- test
- build
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
dart-metrics-analyze:
stage: static
interruptible: true
before_script:
- flutter pub get
script:
- dcm analyze --fatal-style --fatal-performance --no-fatal-warnings --reporter=console lib
tags:
- dev
dart-metrics-check-unused-files:
stage: static
interruptible: true
before_script:
- flutter pub get
script:
- dcm check-unused-files --fatal-unused lib
tags:
- dev
code-generation-mismatch-check:
stage: static
interruptible: true
before_script:
- git status
- flutter pub get
script:
- dart run build_runner build --delete-conflicting-outputs --fail-on-severe
- git diff
- if ((git status --porcelain | Measure-Object -Line).Lines -ne 0) { Write-Error "Some changes in generated files detected"; exit 1 }
tags:
- dev
flutter-test:
stage: test
interruptible: false
before_script:
- flutter clean
- flutter pub get
- flutter pub run build_runner build --delete-conflicting-outputs
script:
- flutter test --update-goldens
tags:
- testing
flutter_build_android_apk:
stage: build
interruptible: false
before_script:
- flutter clean
- flutter pub get
- flutter pub run build_runner build --delete-conflicting-outputs
script:
- flutter build apk --no-tree-shake-icons -t lib/main.dart
artifacts:
paths:
- build/app/outputs/flutter-apk/app-development-release.apk
expire_in: 7 day
tags:
- mobile