Deployment statistics and how to get them from octopus deploy
2019 was a great year for my team at the bank. We delivered features that our merchant’s and customer’s loved while at the same time fixing issues that were inconveniences for them.
My team is doing DevOps, microservices and a bunch of other of last year’s buzz words. If you want to know more about how we work, check out this article by my colleague David.
One of our missions is to “Deliver value each day” to our customers and based on the statistics from 2019 I say we did a pretty good job.
Amongst our 21 microservices that compose our product we did 389 deployments to production! Sweden had 253 working days during 2019 which gives us on average ~1.5 deployments to production per day.
Not all our commits end up directly in production though. We also did:
- 1260 deployments (~5 per working day) to our continuous integration environment.
- 482 to our environment for external testing (~1.9 per working day).
We use Octopus Deploy for all our deployments and the Octopus API supports a number of ways to get statistics on deployments. The one I used to get the above data is
api/reporting/deployments/xml. This API gives us a XML file containing all deployments ever performed by Octopus. We can use this file to analyze, filter and aggregate the data to get the information we want.
To access this API you need to create an API key in Octopus. Log in to Octopus, click on your name in the upper right corner and select Profile. Click on “My API keys” followed by “NEW API KEY”. Optionally give the key a name and copy the key for the next step.
Use your favourite rest client (e.g. Postman, Nightingale, cURL or Invoke-WebRequest) to perform a GET request for
https://<your-octopus-domain>/api/reporting/deployments/xml. Add the API key from step 1 as a custom header named
X-Octopus-ApiKey and save the response body to disk.
Example using Invoke-WebRequest:
The XML file from Octopus looks something like this:
Since it’s an XML file we could use any language we wish to process the data, in our case we put together a simple Node script. The script is shown below and can also be downloaded here. Modify the
filterConditions function to change how to filter the data and
countByProjectName if you wish to aggregate differently.
const xml2js = require('xml2js');
Put the XML file from Octopus (named
deployments.xml in the script) in the same folder as the script and run the following from CLI (ignore any warning that
package.json does not exist):
npm install xml2js
A nice table will be shown on screen of all projects, ordered by most deployments.