Flutter — Jenkins: Getting started

Rana Ranvijay Singh
Globant
Published in
3 min readDec 25, 2019

--

In the end, you will have a working Jenkins Job ready for your Flutter project.

I am assuming you have your Flutter installed and working on your system.

Install Jenkins for mac

Hit this in your terminal and you are set.

brew install jenkins-lts

brew services start jenkins-lts

Follow the instruction to get the initial password and get all the default things installed.

Prerequisite

  1. Create a new flutter project from Android Studio or from the command line.
  2. Push your code on the Git repository.

STEP 1: Configure Jenkins

  1. Find your HOME (/Users/rana.singh) path, use this command.

echo $HOME

3. Find your ANDROID_HOME (/Users/rana.singh/Library/Android/sdk) path, use this command.

echo $ANDROID_HOME

or

echo $PATH

and check for the android path.

4. Note your flutter bin path.

5. Open http://localhost:8080/ to get to the home page of Jenkins.

6. Goto Jenkins > Manage Jenkins > Configure System > Global Properties > Check Environment Variables and Add all the paths.

STEP 2: Create a job

  1. Go to Jenkins home screen and click on create a new Job.
  2. Give your job name and select Freestyle Project.
  3. In the Source Code Management, select the Git option and give your Repository URL.
  4. In Credentials click on Add button > Jenkins.
  5. Enter Username and Password for your git repo and leave rest as it is.

6. Select the Credentials you just mentioned.

7. Scroll down to Build and write this script.

#!/bin/sh
flutter build apk --debug
flutter test

You can choose from different commands which I suppose is self-explanatory.

* flutter build apk --debug
* flutter build apk --release
* flutter build ios --debug
* flutter build ios --release
Of course, you need to have Keystore or certificate configured in your project for release builds.

*flutter test: Runs the test cases.

8. Click Apply and Save.

9. The final step is to click on Build Now options. If everything goes well you should be able to see success logs.

I have demonstrated theses steps in a video: https://www.youtube.com/watch?v=NgoXMw7_RN4&t=

NEXT → Flutter — Jenkins: Trigger build on git push

--

--