Get your free ebook: CI/CD for mobile apps
With CI/CD providers becoming so common these days, you need some compelling reasons to choose one provider over another. Lewis Cianci looks at why you should choose Codemagic for your CI/CD solution.
We’ve all had the experience of trying to get our builds to work on a new machine or the frustrating experience of trying to release an update to an existing app on the Play and Apple stores. We do well as developers to outsource these monotonous tasks to a CI/CD provider. When I was looking for a CI/CD provider, these things were important to me:
- The build process should be as automatic as possible and should respond to Git actions like push 💻
- The site must work on my phone. I should be able to start builds while I am on the road 📳
- Support must exist in some form; preferably, live support where I can ask questions and get answers in real time 🤳
- The ability to run my tests
- It should be easy to start a Flutter build for an app, with options to tease that process out into other functions in the future 🌉
And, in addition to all the above, it had to be free to start out. I’m not going to pay money for something that I haven’t had the opportunity to experience first-hand, so there had to at least be some sort of trial or something. Of course, who would provide an easy-to-use CI/CD solution and also provide support for free?
I had originally placed my code on Azure DevOps (formerly Visual Studio Online), with my apps being built through Visual Studio App Center (VSAC). Trying to get my Flutter apps to build through VSAC was a nonstarter as VSAC doesn’t support it (this issue tracks this feature).
I still wanted to have my code on Azure DevOps because I think it’s great at what it does, and I didn’t want to switch source control providers for no reason. So whatever I went to would have to have the ability to integrate with existing source control systems.
I wound up choosing Codemagic and I’d still choose it in 2020. Here’s why:
1: Codemagic easily connects to existing source control systems
Codemagic supports GitHub, GitLab and Bitbucket out of the box, but you can connect any source control system as long as you have the link to clone it. You can also specify your username and password for the repository in question.
Better still, you can configure for builds to start when you have pushed a certain branch or to start on any branch push.
But what if I don’t want to build on every single code push?
Sometimes you can be pushing updates to your branch but not want the build to run. Codemagic has clever solutions for this - just put
skip ciin your push comments and your build won’t run for that push! 🤓
2: It’s easy to use
Codemagic employs a user interface that I haven’t seen in use on any other source control system. The logical layout of how your build runs helps you to visualise what is happening as part of the build process. It looks like this:
At first glance, it might appear weird, but pretty quickly it makes sense. Your build process is running from top to bottom, so the tests run first, then your build, then the “Publish” step. If your tests fail, then the app won’t be built or published to the store. But what are the plusses around the individual steps? They let you define things to do between steps. This is what you get if you hit the plus above the “Test” step.
As you can see, we can easily run bash scripts at this point to modify our source tree straight after we’ve cloned it. We could use this time to generate our API code or do anything else that is part of the build process.
3: Automatic versioning
Can we just agree that, as cross-platform developers, we have a lot to remember? We have two separate app stores that we have to upload our apps to, two different platforms to deploy to, etc. One of the complexities that arises out of this is making sure that we keep our versions of our apps in sync. Ideally, this means that our versions between our apps should be the same at all times, otherwise trying to debug crashes or other issues becomes a huge mess.
Fortunately, with Codemagic this is as easy as adding this to your build arguments.
--build-name=2.0.$BUILD_NUMBER --build-number=$(($BUILD_NUMBER + 100))
BUILD_NUMBER is an environment variable that increments on each build. So when your builds complete and are pushed to the stores, they will have the same version. You don’t really have to worry about keeping them in sync yourself – it’s done for you.
4: Configuration as code (YAML)
A lot of the time, your build process will just be as simple as your code being checked out, tested, built, and then signed. Sometimes though, it’s not always that easy, and you have to have some custom functionality in your build process that is unique.
Codemagic is happy to process your build for you, but it works equally as well if you want to handle every step yourself. It achieves this by letting you supply a
codemagic.yaml for the build.
This is an excerpt from the
codemagic.yaml file; specifically, the build process.
The first part is the configuration of the keystores and other key properties, and the second part determines how the build process completes by default. So, if you have any commands that you need to run at a specific part in the build process, like generating code or running an automated process, this can run as part of your build. Whatever it is, the point is you can configure your build process however you want.
5: Testing is built in
By default, Codemagic will run your tests as part of the build process. If your tests don’t pass then it doesn’t bother building your project, and definitely doesn’t push it to the stores. Of course, with the current landscape of testing being as good as it is with Flutter, you can write full-blown widget tests and have these execute before your build even runs.
6: It works great, even on your mobile phone
With Visual Studio App Center (VSAC), I could never start builds from my phone. For some reason, whenever I tried to, I just wouldn’t get the option. Actually, I just tried right now, and I still can’t do it.
To do so, you have to use the desktop version of the site, which is bizarre.
With Codemagic, you can start builds wherever you are, whenever you want to. When you navigate to a project, you can choose to build it right then and there.
In fact, you can even go as far as changing the version of Flutter to build against. Again, all from your phone, or small-screened device of your choice.
7: Excellent integration with other systems
When your build is complete or fails for any reason, you probably want to know about it. It would be better if you could perhaps know about it without having to log in to Codemagic to check.
Fortunately, Codemagic provides integration to third-party chat providers like Slack. Whenever your build passes or fails, you can configure for a message to be passed to Slack.
All in all, it’s just a really tidy offering that works well
It’s somewhere where I can build my apps for free, have great support, start builds from my phone, and run tests easily. No doubt as the year goes on, we will see more and more CI/CD providers enter the fray, but Codemagic is a very solid offering for your CI/CD needs today.
Lewis Cianci is a software developer in Brisbane, Australia. His first computer had a tape drive. He’s been developing software for at least ten years, and has used quite a few mobile development frameworks (like Ionic and Xamarin Forms) in his time. After converting to Flutter, though, he’s never going back. You can reach him at his blog, read about other non-fluttery things at Medium, or maybe catch a glimpse of him at your nearest and most fanciest coffee shop with him and his dear wife.
More articles by Lewis: