Get current version number of Atlassian software products

When you are tasked with maintaining server versions of Atlassian products you need to know various information about the lastest release, like version number and the URL to download the software.

The following python function current_version() provides this information for a given product name:

import json
import requests
from packaging.version import parse


product_aka = {
    'jira': 'current/jira-software',
    'confluence': 'current/confluence',
    'bitbucket': 'current/stash',
    'bamboo': 'current/bamboo'
}


def current_version(product):
    if product not in product_aka:
        raise ValueError('Unknown product: {}'.format(product))

    r = requests.get('https://my.atlassian.com/download/feeds/{}.json'
                     .format(product_aka[product]))
    d = json.loads(r.text[10:-1])
    items = {}
    newest = None
    for i in d:
        if 'TAR.GZ Archive' in i['description']:
            v = parse(i['version'])
            if newest is None or v > newest:
                newest = v
            items[v] = {
                'version': i['version'],
                'description': i['description'],
                'platform': i['platform'],
                'releaseNotes': i['releaseNotes'],
                'upgradeNotes': i['upgradeNotes'],
                'zipUrl': i['zipUrl']
            }
    if newest is not None:
        return items[newest]

    raise Exception('No version information found.')


def main():
    for k in product_aka:
        print(k.title())
        print('-' * len(k))
        for key, value in current_version(k).items():
            print('{}: {}'.format(key, value))
        print()


if __name__ == '__main__':
    main()

The requirements are the requests and packaging packages.

The function works for the product names defined in products_aka dict, and can surely be extended to other Atlassian products.

If you run the script, the output looks like this:

Jira
----
description: 8.12.2 (TAR.GZ Archive)
platform: Unix, Mac OS X
releaseNotes: https://confluence.atlassian.com/display/JIRASOFTWARE/JIRA+Software+8.12.x+release+notes
upgradeNotes: https://confluence.atlassian.com/display/JIRASOFTWARE/JIRA+Software+8.12.x+upgrade+notes
version: 8.12.2
zipUrl: https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-8.12.2.tar.gz


Confluence
----------
description: 7.7.4 - Standalone (TAR.GZ Archive)
platform: Unix, Mac OS X
releaseNotes: https://confluence.atlassian.com/display/DOC/Confluence+7.7+Release+Notes
upgradeNotes: https://confluence.atlassian.com/display/DOC/Confluence+7.7+Upgrade+Notes
version: 7.7.4
zipUrl: https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-7.7.4.tar.gz


Bitbucket
---------
description: 7.6.0 (TAR.GZ Archive)
platform: Windows, Unix, Mac OS X
releaseNotes: https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+7.6+release+notes
upgradeNotes: https://confluence.atlassian.com/display/BitbucketServer/Bitbucket+Server+upgrade+guide
version: 7.6.0
zipUrl: https://www.atlassian.com/software/stash/downloads/binary/atlassian-bitbucket-7.6.0.tar.gz


Bamboo
------
description: 7.1.2 - TAR.GZ Archive
platform: Unix, Mac OS X
releaseNotes: https://confluence.atlassian.com/display/BAMBOO/Bamboo+7.1+Release+Notes
upgradeNotes: https://confluence.atlassian.com/display/BAMBOO/Bamboo+Upgrade+Guide
version: 7.1.2
zipUrl: https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-7.1.2.tar.gz

Happy server management!

Update 2021-02-09: Updated algorithm to search for the newest version in each feed.