Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter pipeline with Bitbucket

Tags:

build

flutter

I want to create pipeline for building Flutter(Android/iOS) application on Bitbucket easily. Unfortunately, I have not found any article or guide. Is it possible?

like image 589
Maks Maxx Avatar asked Mar 06 '21 10:03

Maks Maxx


1 Answers

Web

image: cirrusci/flutter

pipelines:
  branches:
    dev:
      - step:
          name: Run unit tests
          script:
            - flutter test
      - step:
          name: Build web
          script:
            - flutter build web
      - step:
          name: Deploy to Firebase
          deployment: production
          script:
            - pipe: atlassian/firebase-deploy:1.1.0
              variables:
                PROJECT_ID: $PROJECT_ID
                KEY_FILE: $FIREBASE_KEY_FILE
                DEBUG: 'true'
                BUILD_DIR: $BUILD_DIR/web/
    main:
      - step:
          name: Run unit tests
          script:
            - flutter pub get
            - flutter test

Android

workflows:
  internal-release:
    name: Internal Release
    environment:
      vars:
        databaseURL: https://my-app.firebaseio.com
        apiKey: asdf
        googleAppID: 1:123:android:456
        AD_MOB_AD_ID: ca-app-pub-123/456
        AD_MOB_APP_ID: ca-app-pub-123~456
        FCI_KEYSTORE_PATH: $FCI_BUILD_DIR/android/app/key.jks
        FCI_KEYSTORE: Encrypted(xxx)
        FCI_KEYSTORE_PASSWORD: Encrypted(xxx==)
        FCI_KEY_PASSWORD: Encrypted(xxx==)
        FCI_KEY_ALIAS: Encrypted(xxx==)
        GCLOUD_SERVICE_ACCOUNT_CREDENTIALS: Encrypted(xxx=)
      flutter: stable
      xcode: latest
      cocoapods: default
    triggering:
      events:
        - push
      branch_patterns:
        - pattern: '*'
          include: true
          source: true
      cancel_previous_builds: true
    when:
      changeset:
        includes:
          - '.'
        excludes:
          - '**/*.yaml'
          - '**/*.yml'
          - '**/*.json'
          - '**/*.md'
          - '**/*.db'
    scripts:
      - |
        # set up key.properties
        echo $FCI_KEYSTORE | base64 --decode > $FCI_KEYSTORE_PATH
        cat >> "$FCI_BUILD_DIR/android/key.properties" <<EOF
        storePassword=$FCI_KEYSTORE_PASSWORD
        keyPassword=$FCI_KEY_PASSWORD
        keyAlias=$FCI_KEY_ALIAS
        storeFile=$FCI_KEYSTORE_PATH
        EOF
      - |
        # set up local properties
        echo "flutter.sdk=$HOME/programs/flutter" > "$FCI_BUILD_DIR/android/local.properties"
      - cd . && flutter packages pub get
      # - cd . && flutter analyze
      # - cd . && flutter test
      - |
        #!/usr/bin/env sh
        if ! command -v yq &> /dev/null
        then
            HOMEBREW_NO_AUTO_UPDATE=1 brew install yq
            exit
        fi
      - cd . && flutter build appbundle --release --build-name=$(yq e .version pubspec.yaml|awk -F+ '{print $1}') --build-number=$PROJECT_BUILD_NUMBER
      - |
        # generate signed universal apk with user specified keys
        android-app-bundle build-universal-apk \
          --bundle build/**/outputs/**/*.aab \
          --ks $FCI_KEYSTORE_PATH \
          --ks-pass $FCI_KEYSTORE_PASSWORD \
          --ks-key-alias $FCI_KEY_ALIAS \
          --key-pass $FCI_KEY_PASSWORD
    artifacts:
      - build/**/outputs/**/*.apk
      - build/**/outputs/**/*.aab
      - build/**/outputs/**/mapping.txt
      - flutter_drive.log
    publishing:
      google_play:
        credentials: Encrypted(xxx=)
        track: internal
        in_app_update_priority: 0
like image 153
Hans Kokx Avatar answered Oct 16 '22 22:10

Hans Kokx