Flutter build app TeamCity config
Template build configuration to build a flutter app with TeamCity
This is a template for TeamCity to build a flutter application. To date I have tested this with 2 different apps on Android and iOS.
- Go to root project
- scroll down and click create template under “Build Configuration Templates”
-
Under general settings we want to make the 2 adjustments. The first one is to change the build number. I use semver to create build numbers. The generated build number will be used in the deployment script in a later post. The second change is to add the artifact paths from our build. The below line will set our build numbers to 0.1.0.5 for example. The 5 will increment with each build by one
Set
Build number format
to: %version_name%.%build.counter% SetArtifact paths
to%system.teamcity.build.workingDir%/build/app/outputs/bundle/release/*.aab => . %system.teamcity.build.workingDir%/build/ios/ipa/*.ipa => . %system.teamcity.build.workingDir%/build/ios/ipa/*.dSYM.zip => .
The .aab file is the android app bundle file thats produced with android builds and the .ipa is the iOS app file and the .dSYM is for debugging purposes. You don’t have to use the .dSYM file but I do for my crashlytics reports. I will show you how to upload it in a future post
- Under
Version Control Settings
I like to only do deployments for my main branch and pull requests. If you want to do the same set theBranch Filter
to
+:<default>
+:refs/pull/*/merge
- I use fastlane for all of my build steps. This is what my lane looks like for ios.
lane :build do |options|
# Before calling match, we make sure all our devices are registered on the Apple Developer Portal
register_devices(
devices: {
"Eddie Detective" => "00008101-001459D02629001E"
}
)
# After registering the new devices, we'll make sure to update the provisioning profile if necessary
sync_code_signing(force_for_new_devices: true, type: "adhoc")
# Getting flutter dependencies
sh("flutter", "pub", "get")
# Installing pods
cocoapods(deployment: true)
# Building with Flutter
build_app(workspace: "Runner.xcworkspace", scheme: "Runner", output_directory: "../build/ios/ipa")
end
Here is the lane for Android
lane :build do |options|
# Building with Flutter
sh("flutter", "build", "appbundle", "--build-number", options[:build_number], "--build-name=" + options[:build_name], "--no-pub")
end
- Next up is the build steps. Under
Build Steps
add 2. The first isBuild iOS
. Because this is a template I want this step to be optional. UnderAdd Condition
add a new condition. The condition will bebuild_ios
and set this toequals true
. Set theWorking Directory
to ios and the custom script will just befastlane build
- The second step is
Build Android
. You want to do the same thing except make the conditional parameterbuild_android
and set the working directory toandroid
. For the script section put this in there. This will build your android app and override the build version and number
bundler exec fastlane build build_name:%version_name% build_number:%build.counter%
- Under VCS triggers, just add the default trigger. If you specified the branch filter from the earlier step then setting the default trigger to * will only build on the default and pull request branches
- This step is optional but I do like to add the commit status publisher feature. You can add that in build features
- Under the Parameters section make sure your parameters look like this
- You can now create a new build configuration based on this template. It will ask you to supply the
build_ios, build_android and version_name
parameters. One thing to note, I manually update theversion_name
parameter when I’m changing my minor, major and patch versions