Dev Diary #1

Being a developer is an ongoing fight with the tools, languages and bugs. In this series I write about my everyday challenges as a software developer.

Todays goal: Setup the CI to create and distribute an Android APK

Our code is hosted on GitLab and I have a already working Cake Script which creates an APK. Easiest way is to use the integrated GitLab CI, so I need to add a Windows Runner. May I need to add that the Android APK is developed with Xamarin.

Create an Azure VM and install GitLab Multi Runner

I have created a new VM of type “Visual Studio 2015 Community with UWP & Azure SDK on Windows 10 Enterprise”, so everything I need is preinstalled and I don’t need to struggle with Windows Server. First Problem: I could not connect via RDP. The Solution was to manually add VMAccess rights to the user with PowerShell:

Set-AzureRmVMAccessExtension -ResourceGroupName "myResourceGroup" -VMName "myVMName" -Name "DefaultVMAccess" -Location WestEurope

Look at MSDN for more Details.

Download and install GitLab CI Runner

Easiest way to do this is following the official Install on Windows Guide provided by GitLab:

I also run into another problem: 
FATAL: Failed to start gitlab-runner: The service did not start due to a logon failure.

This can be solved by adding SeServiceLogonRight to the user used for the gitlab-runner. And, as always StackOverflow showed me how to do this:

The build job freezed …

I added a very simple .gitlab-ci.yml file to my project which just invoke the build.ps1 from Cake and the result was just a spinning circle:

Spinning wheel of nothing happens :(

I waited half and hour … still the spinning wheel. Contrary to the GitLab CI documentation, PowerShell scripts are not automatically executed with PowerShell. (Changing the default executor to ‘powershell’ in config.toml didn’t help as well.) But, what solved the problem was adding @powershell in the .gitlab-ci.yml:

stage: build
- xamarin
- "@powershell ./build.ps1"

Now the script runs, but the build still failed because Visual Studio was not up to date with all the tools I need to build the Android APK.

Installing Update 3 of Visual Studio took a way to long. Or rather, the whole afternoon. Maybe a A1 instance is fine for a build host, but not for installing VS Updates. And to be honest, I wasted the whole evening in playing a new computer game … 🙈

But, CI build is running now and the APK is created. So Upload to Hockey App is the task for tomorrow morning. ☺️