Automating Upgrades with MariaDB.Org Downloads REST API

You are viewing an old version of this article. View the current version here.

The MariaDB Foundation maintains a Downloads REST API. See the Downloads API documentation to find out all the tasks that you can accomplish with this API. Generally speaking, we can say that it provides information about MariaDB products and available versions. This allows to easily automate upgrades for MariaDB and related products.

Usage Example: Checking When a Version Becomes GA

A trivial use case is to write a script that checks the list of MariaDB GA major versions and, when something changes, send us an email. So we can test the newest GA version and eventually install it.

The script in this example will be extremely simple. We'll do it this way:

  • Retrieve the JSON object describing all MariaDB versions.
  • For each element of the array, only show the release_id and release_status properties, and concatenate them.
  • Apply a filter, so we only select the rows containing 'stable' but not 'old' (so we exclude 'Old Stable').
  • From the remaining rows, only show the first column (the version number).
  • If the results we obtained are different from the previously written file (see last point) send an email.
  • Save the results into a file.

This is something that we can easily do with a Unix shell:


    curl | \
    jq -r '.major_releases[] | .release_id + " " + .release_status' | \
    grep -i 'stable' | grep -v 'old' | \
    cut -d ' ' -f 1

touch ga_versions
previous_ga_versions=$( cat ga_versions )

if [ "$current_ga_versions" != "$previous_ga_versions" ];
    mail -s 'NOTE: New MariaDB GA Versions' <<< 'There seems to be a new MariaDB GA version! Yay!'

The only non-standard command here is jq. It is a great way to manipulate JSON documents, so if you don't know it you may want to take a look at jq documentation.

Content initially contributed by Vettabase Ltd.


Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.