The case of the self-cancelling Azure DevOps pipeline

The Issue Today I came across a strange issue with a reasonably old multi-stage YAML pipeline, it appeared to be cancelling itself. The Build stage ran OK, but the Release stage kept being shown as cancelled with a strange error. The strangest thing was it did not happen all the time. I guess this is the reason the problem had not been picked up sooner. If I looked at the logs for the Release stage, I saw that the main job, and meant to be the only job, had completed successfully....

October 29, 2021 · 2 min · Richard Fennell

Making SonarQube Quality Checks a required PR check on Azure DevOps

This is another of those posts to remind me in the future. I searched the documentation for this answer for ages and found nothing, eventually getting the solution by asking on the SonarQube Forum When you link SonarQube into an Azure DevOps pipeline that is used from branch protection the success, or failure, of the PR branch analysis is shown as an optional PR Check The question was ‘how to do I make it a required check?...

September 21, 2021 · 1 min · Richard Fennell

How I dealt with a strange problem with PSRepositories and dotnet NuGet sources

Background We regularly re-build our Azure DevOps private agents using Packer and Lability, as I have posted about before. Since the latest re-build, we have seen all sorts of problems. All related to pulling packages and tools from NuGet based repositories. Problems we have never seen with any previous generation of our agents. The Issue The issue turned out to be related to registering a private PowerShell repository. $RegisterSplat = @{ Name = 'PrivateRepo' SourceLocation = 'https://psgallery....

July 16, 2021 · 1 min · Richard Fennell

Automating the creation of Team Projects in Azure DevOps

Creating a new project in Azure DevOps with your desired process template is straightforward. However, it is only the start of the job for most administrators. They will commonly want to set up other configuration settings such as branch protection rules, default pipelines etc. before giving the team access to the project. All this administration can be very time consuming and of course prone to human error. To make this process easier, quicker and more consistent I have developed a process to automated all of this work....

June 10, 2021 · 2 min · Richard Fennell

Getting the approver for release to an environment within an Azure DevOps Multi-Stage YAML pipeline

I recently had the need to get the email address of the approver of a deployment to an environment from within a multi-stage YAML pipeline. Turns out it was not as easy as I might have hoped given the available documented APIs. Background My YAML pipeline included a manual approval to allow deployment to a given environment. Within the stage protected by the approval, I needed the approver’s details, specifically their email address....

May 15, 2021 · 1 min · Richard Fennell

Fixing my SQLite Error 5: 'database is locked' error in Entity Framework

I have spent too long today trying to track down an intermittent “SQLite Error 5: ‘database is locked’” error in .Net Core Entity Framework. I have read plenty of documentation and even tried swapping to use SQL Server, as opposed to SQLite, but this just resulted in the error ‘There is already an open DataReader associated with this Connection which must be closed first.’. So everything pointed to it being a mistake I had made....

February 12, 2021 · 1 min · Richard Fennell

What to do when moving your Azure DevOps organisation from one region to another is delayed.

There are good reasons why you might wish to move an existing Azure DevOps organisation from one region to another. The most common ones are probably: A new Azure DevOps region has become available since you created your organisation that is a ‘better home’ for your projects. New or changing national regulations require your source stored in a specific location. You want your repositories as close to your workers as possible, to reduce network latency....

January 25, 2021 · 2 min · Richard Fennell

Running UWP Unit Tests as part of an Azure DevOps Pipeline

I was reminded recently of the hoops you have to jump through to run UWP unit tests within an Azure DevOps automated build. The key steps you need to remember are as follows Desktop Interaction The build agent should not be running as a service it must be able to interact with the desktop. If you did not set this mode during configuration this post from Donovan Brown shows how to swap the agent over without a complete reconfiguration....

December 8, 2020 · 2 min · Richard Fennell

Out of Memory running SonarQube Analysis on a large projects

Whilst adding SonarQube analysis to a large project I started getting memory errors during the analysis phase. The solution was to up the memory available to the SonarQube Scanner on the my build agent, not the memory on the SonarQube server as I had first thought. This is done with an environment variable as per the documentation, but how best to do this within our Azure DevOps build systems? The easiest way to set the environment variable `SONAR_SCANNER_OPTS` on every build agent is to just set it via a Azure Pipeline variable....

December 1, 2020 · 1 min · Richard Fennell

Getting confused over Azure DevOps Pipeline variable evaluation

Introduction The use of variables is important in Azure DevOps pipelines, especially when using YML templates. They allow a single pipeline to be used for multiple branches/configurations etc. The most common form of variables you see is are the predefined built in variables e.g. $(Build.BuildNumber) and your own custom ones e.g. $(var). Usually the value of these variables are set before/as the build is run, as an input condition. But this is not the only way variables can be used....

November 27, 2020 · 3 min · Richard Fennell