bookmark_borderFlutter GitLab CI/CD DevOps

  1. Create .gitlab-ci.yml file in Project root dir
    in the same level of lib folder create file .gitlab-ci.yml
  2. Get a docker:image
    There are some flutter docker images available you can select one or even use your own Docker image

    Flutter docker images examples:
    cirrusci/flutter:stable (github)
    kattwinkel/flutter-android (github)

    Then add it in .gitlab-ci.yml file:
    image: cirrusci/flutter:stable
  3. Define your stages
    Now you need to define stages like that:
    For example:
    stages:
    - test
    - build

    Then start to define tasks that each stage should run:
    For example for stage test:


    test:
    stage: test
    script:
    - flutter packages get
    - flutter packages upgrade
    - flutter test
    interruptible: true

    For example for stage build:


    build:
    stage: build
    script:
    - flutter build apk
    artifacts:
    expire_in: 1 week
    paths:
    - build/app/outputs/apk/release/app-release.apk
    interruptible: true

    Full Example

    .gitlab-ci.yml

    image: cirrusci/flutter:stable

    stages:
    - test
    - build

    test:
    stage: test
    script:
    - flutter packages get
    - flutter packages upgrade
    - flutter test
    interruptible: true

    build:
    stage: build
    script:
    - flutter build apk
    artifacts:
    expire_in: 1 week
    paths:
    - build/app/outputs/apk/release/app-release.apk
    interruptible: true

    You can add more stages like deploy , upgrade , publish etc..