Setting Up Jenkins for Flutter App on macOS
Introduction: In this blog post, we will walk through the process of setting up Jenkins on macOS to automate the building and testing of your Flutter applications. Jenkins is a popular open-source automation tool that helps to integrate and automate various stages of your Flutter app's development lifecycle.
Way 1: Pipeline Flow
For setting up Jenkins with a pipeline flow, you can refer to the following Stack Overflow discussion to resolve issues like "Flutter not found": Flutter Jenkins Flutter not found issue
https://stackoverflow.com/questions/75422046/flutter-jenkins-flutter-not-found-issue
Step 1: Install Jenkins on macOS
First, we need to install Homebrew if you don't have it already. Open your terminal and run the following command:
After Homebrew is installed, run the following command to install Jenkins:
Include Screenshot: Install Jenkins using Homebrew
Step 2: Start Jenkins
Once the installation is complete, start Jenkins by running the following command in your terminal:
Open your browser and go to
http://localhost:8080
. You should see the Jenkins setup page.Include Screenshot: Jenkins running on localhost
Step 3: Unlock Jenkins
On the setup page, Jenkins will ask you for an unlock key. You can find this key by running the following command in your terminal:
Copy the key and paste it in the Jenkins setup page to unlock Jenkins.
Include Screenshot: Unlock Jenkins page
Step 4: Install Required Plugins
- After unlocking Jenkins, it will prompt you to install recommended plugins. Click on the "Install suggested plugins" button to proceed.
Step 5: Set Up Flutter SDK
To build a Flutter app, you need to have the Flutter SDK installed on your macOS machine. Follow these steps:
- Download the Flutter SDK from Flutter's official site.
- Extract the downloaded ZIP file and add the
flutter/bin
directory to your system's PATH.
Verify your Flutter installation by running the following command in your terminal:
Step 6: Create a Jenkins Pipeline for Your Flutter App
- In Jenkins, create a new pipeline project by selecting “New Item” > “Pipeline”.
- In the pipeline configuration, under the “Pipeline” section, define the stages of your Flutter app build process.
Example Jenkinsfile
for a Flutter app:
Way 2: Freestyle Flow
Generate Bitbucket Password
- You will need to generate an app password for Bitbucket to authenticate Jenkins to access your repository.
Create Freestyle Project in Jenkins
- In Jenkins, create a new Freestyle project.
Configure the Git Repo
- In the Freestyle project configuration, set up the Git repository (Bitbucket in this case) with your repository URL and authentication method using the generated Bitbucket password.
Include Screenshot: Freestyle Project Configuration for Git Repo
#!/bin/sh
flutter doctor -v
flutter pub get
flutter build apk --release
Reference:
https://medium.com/globant/flutter-jenkins-getting-started-4d2e036567b
Comments
Post a Comment