Wrapcode

Xamarin Android - Continuous Deployment to HockeyApp using Visual Studio Team Services (VSTS)

| 5 min read

> This article is part of blog series VSTS, Xamarin and Continuous Integration. Why does it matter? > > * For instructions on integrating Xamarin Android continuously using VSTS, see article Xamarin Android – Continuous Integration using Visual Studio Team Services (VSTS)

Assuming we have build artifacts ready from the build definition we created (refer **this **article if you haven't).

The role of our release definition is -

  1. It use the files (binaries and packages) that got created from build
  2. Upload these packages and binaries to HockeyApp
  3. HockeyApp will trigger the email to beta testers or focus groups

Prerequisites -

We need following things in place before we can start creating release definition for Xamarin iOS app -

  1. Permisssions - You should have permissions to manage builds, process and definitions. If not, please ask your VSTS administrator to provide you with required permissions on specific project.
  2. HockeyApp account (API Key and App ID)
  3. HockeyApp extension (you can install it on your VSTS by following instructions)
  4. Xamarin Android specific build definition with required artifacts

Getting the essentials up and running

Retrieving HockeyApp API Key -

  1. Login to HockeyApp
  2. Go to Settings (by clicking Avatar on top right corner) -> API Keys
  3. Create a new API Token (or use existing if you already have) 2016-07-12 16_47_19-API Tokens – HockeyApp
  4. Copy newly generated API key

Adding HockeyApp Service -

  1. Login to VSTS, Select Repository and click on Settings icon on top right corner
  2. Go to Services tab
  3. Add New Service Endpoint -> HockeyApp 2016-07-12 16_48_08-Endpoint_ HockeyApp - Microsoft Team Foundation Server
  4. Chose a name for this service endpoint e.g. HockeyApp-Connection and enter API key that you generated in earlier steps 2016-07-12 16_48_50-Endpoint_ HockeyApp - Microsoft Team Foundation Server

Retrieving App ID -

  1. Go to HockeyApp dashboard
  2. Add a new iOS app. Make sure you provide exact package name while creating a new app.
  3. Copy App ID provided under Manage App dashboard - 2016-07-17 17_45_32-Credit Card Validator (com.rapidcircle.creditcardvalidator) – HockeyApp

Create a new release definition -

  1. Open VSTS dashboard and select Xamarin iOS project
  2. Head over to Release tab
  3. Click on + icon to create a new release definition.
  4. Select an empty template

Create new release definition - VSTS Create new release definition - VSTS[/caption]

  1. Hit Next >
  2. Select the Source Build Definition which you want to link to the release definition. If you want to deploy the app as soon as a build is succeed Tick the Continuous Deployment checkbox. Also select the queue in which Mac agent is present. 2016-07-12 16_45_00-Explorer - Visual Studio Team Services
  3. Now you have default Release definition template in place. You can rename Release Definition to your choice. You can also rename environment. Right now we are dealing with only single environment as this is less complex solution. You can define release tasks based on different environments if you wish to be. I will probably blog about it in future.

2016-07-12 16_45_37-Deploy to HockeyApp - Visual Studio Team Services

Adding tasks to Release Definition

  1. Hit "Add tasks" button
  2. Click on Deploy in left pane if it is not already selected and Click Add button in front of Release Task named "HockeyApp" 2016-07-12 16_46_13-Deploy to HockeyApp - Visual Studio Team Services
  3. Once you add HockeyApp task, it should be added in an environment in the background. Click Close. Bad, bad UX.
  4. This will be the default HockeyApp task with no values. Select the service you created from HockeyApp connection dropdown (this is why you should name it right, to avoid confusions) 2016-07-12 16_49_21-Deploy to HockeyApp - Visual Studio Team Services
  5. Paste App ID you copied from HockeyApp > Manage Apps section
  6. Click Browse (...) button in front of Binary File Path
  7. Select following folder path - Linked Artifacts -> Build Definition Name -> drop (folder) -> .apk (not the unsigned one) e.g. in our case the path looks something like this

2016-07-17 17_48_14-Release major to hockey app - Visual Studio Team Services Note - *Do not select apk.unsigned*

  1. Save the definition.
  2. You can either queue the build or manually trigger Release to check if everything is fine. If you have provided correct Keys and IDs and the build manifests are correct, you will see a new build pushed to HockeyApp. If everything is configured correctly, your build should trigger based upon trigger event of your choice and once the build is successfully finished, release definition should deploy it automatically to HockeyApp.

There is a way to deploy the application package directly to Google Play Store but I prefer having it tested by focus groups / testers before pushing it to Play Store. But it's up to you how you want to go.

Thanks and keep launching, RP