Xamarin DevOps with VSTS - Deploying To HockeyApp

This post continues the series on Visual Studio Team Services and shows how we can deploy Xamarin Android and iOS applications to HockeyApp from VSTS.

So far in this series of posts we have covered Continuous Integration builds and can now build versioned Xamarin Android and iOS apps.

Mobile DevOps comprises Continuous Integration (CI), Continuous Delivery (CD) and Continuous Monitoring (CM).

HockeyApp provides both Continuous Delivery and Continuous Monitoring functionality.

Resources

  • Get HockeyApp: Bring Devops to mobile app development is a great starting point for HockeyApp. It shows how to buy/trial HockeyApp and has links to installing the HockeyApp VSTS extension from the VSTS Marketplace.

  • The HockeyApp VSTS extension. This pge contains instructions and defines the features the extension provides:-

  • A service endpoint for connecting to HockeyApp
  • A build task to deploy your app to HockeyApp
  • The HockeyApp widget

Key Points

  • We can deploy to HockeyApp with a single build task added to the Build Definition.

  • We should consider when we actually want to deploy to HockeyApp - probably not from a Continuous Integration build.

  • We can install the HockeyApp app to iOS and Android devices and install our apps using this.

  • The free HockeyApp account supports two apps. Note if you wish to have different deployments of an app, say Alpha for a Scrum team and then a Beta for the wider audience of Stakeholders then each of these count as an app so you will have to use a paid for HockeyApp account.

Reviewing the Build Defintions

Presently we have two Continuous Integration builds, one each for Android and iOS. These are trigged when source code is checked into the master branch of the Git repository and will build a signed, versioned application which can be manually side loaded onto a device.

We can clone these builds to create a Release Build for each of the two platforms which is triggered manually/scheduled and will deploy the application to HockeyApp. These Release builds could be scheduled to run each night so a new build is ready to test each morning for example.

Cloning the builds

In VSTS click on the Build page and then right click on the HellowDevOps Android CI build:-

Click on the Clone... option. This will create a copy of the existing Build Definition:-

We can now Save this new Build Defintion with a new name. Click the Save button and edit the Name field to HelloDevOps Android Release:-

Click the OK button and the new Release build will be saved:-

Repeat these steps for the HelloDevOps iOS CI build defintion, naming the copy as HelloDevOps iOS Release. We should now have a Release build defintion for each of the platforms:-

Creating a HockeyApp account

The HockeyApp Pricing page shows it is free for 2 Apps so we will use this to get started. If you need to purchase a paid for plan then this can be done from the Visual Studio Marketplace as detailed on the Get HockeyApp: Bring Devops to mobile app development:-

Click the Sign Up For Free button. We can now enter our details and check the I'm a developer option:-

Click the Register button.

We are now presented with the HockeyApp dashboard:-

A confirmation email will have been sent so open that and click on the Confirm Registration link. The HockeyApp dashboard will display a confirmation message that we are now signed in:-

Install the HockeyApp VSTS Extension

We can install the HockeyApp VSTS extension from the Visual Studio Marketplace listing:-

Click the Install button and the Account Selection dialog will be displayed:-

Confirm that the correct account is selected and press the Continue button. The installation will be verified and the Confirmation dialog page will be displayed:-

Click the Confirm button and the extension will be installed into the VSTS account:-

Click the Close button and we return to the Marketplace listing.

Create a HockeyApp Connection

We can now follow the instructions at How to use HockeyApp with Visual Studio Team Services (VSTS).

We now need to create an API token in HockeyApp so use the link Create API Token and optionally enter a name for the token:-

Click the Create button and the API Token will be created:-

Returning to VSTS click on the Settings cog to open the control panel:-

Click on the Services tab:-

Click on the + New Service Endpoint:-

Choose the HockeyApp option and the Add new HockeyApp Connection dialog will be displayed. Enter a name for the connection and paste in the API Token:-

Click the OK button and the HockeyApp connection will be created:-

Deploy the Android App to HockeyApp

Now that we have a connection between VSTS and HockeyApp we can build and deploy the apps to HockeyApp. We can create a new app in HockeyApp explicitly or we can have it done automatically via the HockeyApp build task. The instructions can be found in How to create a new app.

We will take advantage of the HockeyApp build tasks ability to automatically create the app in HockeyApp.

On the VSTS Build page edit the HelloDevOps Android Release build definition. Click the + Add build step... button. The Add tasks dialog will be displayed. Select the Deploy category and we can see that there is a HockeyApp build task available:-

Click the Add button and then the Close button. The Deploy to HockeyApp build step has been added to the definition. Click on it to select it:-

In the HockeyApp Connection field use the drop down to select the BlogAboutXamarin HockeyApp endpoint we created earlier.

Edit the Binary File Path field to have the value $(build.binariesdirectory)/$(BuildConfiguration)/*.apk.

We can check the Notify Users? option so that they get an email each time an app is deployed to HockeyApp:-

Click the Save button and then the OK button on the Save dialog.

Now we can perform a build and check that the app is deployed to HockeyApp. Click the Queue Build button. Click the OK button on the Queue Build dialog. We can see from the build output that the HockeyApp build task ran ok:-

Now we can return to the HockeyApp dashboard and see if the app deployed:-

It worked! Next we can take a look at the dashboard for the Android App. Click on the HelloDevOps Android | Beta app:-

From this we can see everything looks good. We can queue up another build in VSTS to confirm that the Code column is working correctly to version each deployed app inline with the build number:-

We can see that the apps are being correctly versioned as detailed in the post Xamarin Dev Ops with VSTS - Versioning Apps For HockeyApp.

We can click on one of the releases and see the detail for that version:-

Note the Download link, if we click this we are taken to a download page. If we access this page in a browser on an Android device we can manually install the application. Alternatively we can install the HockeyApp app onto the Android Device and use this to install new versions.

The Apps for HockeyApp page has download links for the different platforms including Desktop Windows and Mac and mobile versions for Android and iOS.

Deploy the iOS App to HockeyApp

Now we can repeat the process for deploying the iOS app to HockeyApp.

Once again we will take advantage of the HockeyApp build tasks ability to automatically create the app in HockeyApp.

On the VSTS Build page edit the HelloDevOps iOS Release build definition. Click the + Add build step... button. The Add tasks dialog will be displayed. Select the Deploy category and we can see that there is a HockeyApp build task available:-

Click the Add button and then the Close button. The Deploy to HockeyApp build step has been added to the definition. Click on it to select it:-

In the HockeyApp Connection field use the drop down to select the BlogAboutXamarin HockeyApp endpoint we created earlier.

Edit the Binary File Path field to have the value **/*.ipa.

Using wildcards is easier for iOS builds due to the more complex directory structure. For example the ipa file will be built to:-

  • Macincloud Agent:- /Users/xxxx/vsts-agent/_work/3/s/iOS/bin/iPhone/Release/HelloDevOps.iOS-1.0.11.ipa

  • Local X-Platform Agent:- /Users/richardwoollcott/myagent/_work/3//s/iOS/bin/iPhone/Release/HelloDevOps.iOS-1.0.11.ipa

We can use build variables if the wildcards are not satisfactory.

We can check the Notify Users? option so that they get an email each time an app is deployed to HockeyApp:-

Click the Save button and then the OK button on the Save dialog.

Now we can perform a build and check that the app is deployed to HockeyApp. Click the Queue Build button. Click the OK button on the Queue Build dialog. We can see from the build output that the HockeyApp build task ran ok:-

Now we can return to the HockeyApp dashboard and see if the app deployed:-

Great this worked too! Next we can take a look at the dashboard for the iOS App. Click on the HelloDevOps iOS | Beta app:-

From this we can see everything looks good. We can queue up another build in VSTS to confirm that the Build column is working correctly to version each build and deployed app:-

At this point we can see that there was a problem with the build numbers initially. When I looked into this I found it was because all of the versions of the ipa file were available in the folder so the first version of the ipa was always being deployed to HockeyApp.

To fix this problem I edited the Build Definition via the Repository tab and set the Clean field to true:-

We can see that the apps are now being correctly versioned as detailed in the post Xamarin Dev Ops with VSTS - Versioning Apps For HockeyApp.

We can click on one of the releases and see the detail for that version:-

This concludes this post. It is likely that moving to use VSTS Release Management is a next step. This uses the HockeyApp Build Step and as such is an easy change to make, deleting or disabling the build step we have added in this post.

A likely scenario for Release Management might be to manage an Alpha build to a Scrum team and then a manual approval to deploy the app as a Beta to a wider audience of stakeholders for example.

Richard Woollcott

Read more posts by this author.

Taunton, United Kingdom