Flutter CI/CD = Fastlane+gitlab-runner+TestFairy

Atul anand
3 min readAug 11, 2019

--

In this tutorial, we will be setting up CI/CD environment for your Flutter projects using Fastlane with Gitlab runner. Here, we are using Gitlab-runner only to trigger Fastlane because Fastlane is capable enough to build the code and deployment on testfairy.

If we are using Fastlane we need to pull a code every time and switch to each android and ios folder then write a command manually. After gitlab-runner and Fastlane integration we are able to mitigate the manual task

In Simple worlds — Build a code in every git commit or push :)

Prerequisite

You are all set with the android and ios build with flutter

Let’s Started

  1. Install Fastlane

2. After installation go to your project cd ios, cd android and run the command Fastlane init

then you have a folder structure like this

There are many tutorials for Fastlane over the internet but they are very confusing so we need basic command in Fastlane or you can create your own custom commands.

Example of Fastfile

These commands are more than enough to build test (in this SS test commands are not present)and deploy over and distributed app like HOCKEY, Testfairy.

Gitlab Runner Integration

First, we will add a .gitlab-ci.yml file to the root directory of the project by terminal:

touch .gitlab-ci.yml

Now, we will install Gitlab Runner on MacOS.

  1. Download the binary for your system:
$ sudo curl — output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64

2. Give it permissions to execute:

$ sudo chmod +x /usr/local/bin/gitlab-runner

After you installed Runner, you need to register runner for your project.

  1. Run the following command:
$ gitlab-runner register

2. Enter your GitLab instance URL:

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com) https://gitlab.com

3. Enter the token you obtained to register the Runner. You can get your token in Gitlab Setting -> CI/CD -> Runner

Please enter the gitlab-ci token for this runner
Your token

4. Enter the tags associated with the Runner, you can change this later in GitLab’s UI:

Please enter the gitlab-ci tags for this runner (comma separated): ios

5. Enter the Runner executor:

Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell:
shell

If you don't know your executor select ‘shell’

My .yml file looks like this.

If all looks good then after every commit on Dev branch build will be triggered and tester got a new mail with the new build from testfairy.

IF you got any error don’t panic just take a deep breath.

  1. You need to give permissions to your folder.
  2. Sometimes you need to run a Pod install.
  3. You may need to delete Runner.xcworkspace.
  4. Open your ios project in Xcode and add certificates stuff there.

Any Query Please write on ~ . atul.dc@gmail.com

--

--