Search code examples
androidfluttercicdcodemagic

Step 3 script `_` exited with status code 1 - Codemagic


I have monorepo that contains Flutter apps. In my parent project I have melos installed and this is my codemagic.yaml:

workflows:
  test-app-workflow-android:
    name: Test App workflow (Android)
    working_directory: $PWD/apps/test_app
    instance_type: mac_mini_m1
    max_build_duration: 60
    environment:
      flutter: master
      java: 1.8
    triggering:
      events:
        - push
      branch_patterns:
        - pattern: "master"
          include: true
          source: true
      cancel_previous_builds: true
    scripts:
      - name: Check Dart Version
        script: |
          dart --version
      - name: Set up local.properties
        script: |
          echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"
      - name: Get Flutter packages
        script: |
          flutter packages pub get
      - name: Flutter analyze
        script: |
          flutter analyze
    artifacts:
      - build/**/outputs/**/*.apk
    publishing:
      email:
        recipients:
          - [email protected]
        notify:
          success: true
          failure: true
    cache:
      cache_paths:
        - $FLUTTER_ROOT/.pub-cache

It seems that no matter what script I use, I get this error:

Build failed :|
Step 3 script `Check Dart Version` exited with status code 1

Making the codemagic.yaml not to work on my side at all. Any ideas what I might have missed?


Solution

  • version 2:

    1. try to remove $PWD from working_directory: $PWD/apps/test_app line. It should use path starting from repository root or you can use $CM_BUILD_DIR

    2. next you need to provide full path to the dart command because it's not in the system $PATH. This work fine:

    $FLUTTER_ROOT/bin/dart --version
    

    FLUTTER_ROOT variable already pre-defined for you.