CI / CD with App Center

Abstract

Delivering mobile applications to testers or to stores is always a hard task. However, it is a very important job. Instead of web applications, when it comes to distributing mobile applications, we must think about device models, operating systems and their different versions.

The App Center is a Microsoft tool that assists us in adopting the practice of DevOps in the mobile application scenario. With this tool it is possible to configure a DevOps treadmill, deliver releases of your application for testers, automate the process of publishing in stores (App Store and Google Play), obtain indicators and tracking of crashes. All of this in a simple and automated way.

Introduction

The purpose of this article is to demonstrate how we can create a CI / CD pipeline in the App Center. For the article not to be too long, the Analytics and Diagnostics services will not be covered here.

Requirements

The platforms and frameworks supported by the App Center are:

  • Native iOS – Swift and Objective-C
  • Native Android – Java and Kotlin
  • Windows – UWP, WPF and WinForms
  • React Native – iOS and Android
  • Xamarin – iOS and Android

The code repositories supported by the App Center are:

  • Azure DevOps
  • GitHub
  • Bitbucket
  • GitLab

 

Creating the organization

On the App Center home screen, in the upper right corner, select “Add new” and then “Add new organization”.

Then, add a name for your organization and click the “Add new organization” button.

Creating a project

In the side menu, choose the organization in which you want to create a new project and click on “Apps” in the submenu.

In the upper right corner, select “Add new app”.

Enter the information for your app. Name, Release Type, Operating System and the development platform you are using.

Android

 iOS

In the end, within our organization, we will have two projects, one for Android and another for iOS, as shown in the following image:

Integrating with code repository

Open your project and in the left side menu select “Build”. Then, select the repository of your choice.

After that, you will need to log in to your repository access credentials and grant permission for the App Center to integrate with your account.

Configuring build

After opening your project, select the option “Build” in the left side menu.

All existing branches in your repository will be displayed. Select the desired branch.

After selecting the branch, click on the “Configure build” option.

Build App – Android

In this step, the Android application build configuration will be made.

Project – Field designed to identify the project that will be executed. Often the App Center itself already identifies, as in the image below for example.

Configuration – You can run the build in Debug or Release mode.

SDK version – In this example I am running a Xamarin.Forms project, so I can choose which version of the SDK I want to run. (In this case it is an android application, so it is the Xamarin.Android SDK).

Build scripts – It is possible to add scripts to the build.

Build frequency – Here you can define how much your build will be automated. For example, the build can be performed every time a push is made on the branch, or just manually. That is, you need someone to enter the App Center and “start” in the build.

Build Android App Bundle – Create an App Bundle for your apk. Learn more about Android App Bundle at: https://developer.android.com/guide/app-bundle?hl=pt-br

Automatically increment version code – Automatically increment a version number.

Build number format – If the option “Automatically increment version code” is activated, it is possible to define the version number that will be automatically incremented, which can be an incremental ID or a Timestamp.

Sign builds – Android

In order for you to create Release mode versions of your Android application and distribute the APKs to testers, it is necessary to sign your application using a Keystore. In this session it is necessary to add the .keystore file and inform its environment variables (Keystore password, Key alias and Key password).

Build App – iOS

In this step, the iOS application build configuration will be made.

Project – Field designed to identify the project that will be executed. Often the App Center itself already identifies. If he doesn’t, select the project “.iOS.csproj”.

Configuration – You can run the build in Debug or Release mode.

SDK version – In this example I am running a Xamarin.Forms project, so I can choose which version of the SDK I want to run. (In this case it is an android application, so it is the Xamarin.iOS SDK).

Build scripts – It is possible to add scripts to the build.

Build type – Define the type of build, whether it will be of the Device or Simulator type. The simulators are faster. However, they cannot be distributed for testing on devices.

Build frequency – Here you can define how much your build will be automated. For example, the build can be performed every time a push is made on the branch, or just manually. That is, you need someone to enter the App Center and “start” in the build.

Automatically increment version code – Automatically increment a version number.

Build number format – If the option “Automatically increment version code” is activated, it is possible to define the version number that will be automatically incremented, which can be an incremental ID or a Timestamp.

 Sign builds

In order for you to create Release mode versions of your iOS application and distribute IPAs to testers, it is necessary to sign your application using a certificate and a Provisioning Profile. In this session it is necessary to add the .mobileprovision files, .p12 file and inform the certificate password.

Environment variables

You can define as many environment variables as you want. Thus, your application can, as in the example in the image below, have a different api’s url according to each environment.

Test on a real device

Perform a test on a real device. A very simple test is done, just to see if your application opens on a real device. This is a free option. The only disadvantage is that the build time will be longer.

 Distribute builds

Enabling this option, you can configure to automate the distribution of your apk. In other words, as soon as the build is finished, distribution is already made to the testers or stores that you want.

Advanced

Build status badge – Here you can create a badge with the build status of your application.

 Executing

After executing a build, you will be presented with a screen like the following image. In which you can see the build output. That is, follow the build log and analyze possible errors, if they exist.

Distributing a release of your app to testers

Access your application on the App Center portal and in the side menu select Distribute -> Releases. Then select “New release”.

You have the option to distribute an artifact (apk / ipa) if you have already generated it on your machine. Just upload the file.

However, in this example we will use an artifact generated by the App Center build. Then, select the option “Distribute an Existing Build”.

The first step is to select the desired Branch, remembering that only branches that already have a build configured and executed will be displayed in this step.

Select the build version of the respective branch selected in the previous step.

It is possible to add a note for your release. This note will appear to your testers.

Select which group of testers you want to distribute this version to. You can create a group with email from the testers.

Your version will be distributed and will appear in the list of Releases. In the “testers” tab you can find out who it was distributed to and add new testers for this specific release, if necessary.

Getting here, you have completed the necessary steps to distribute your App to a group of testers in the App Center.

Summary

App Center is a very simple and intuitive tool, this article showed how to create a CI and CD to deliver apps to testers. I hope this article will help you deliver your mobile applications to testers more quickly and easily.

Post a Comment

* indicates required