How to obtain latest version number?

Hi guys,

is there any easy possibility to obtain the latest available version number from mattermost server?
Just want to automate the update process for self-hosted installations.

Cheers!

You can use the links in latest.mattermost.com. It will redirect you to the package with the latest version.

Yeah but I cannot check against installed version there :confused:
I know the installed version number, and I want to check if latest version > installed version…

You’ll need to parse the url. And then compare with your installed version.

Hi,

version calculation can be difficult, so I suggest to remove the dots on the version strings so you can compare the numbers with each other. If you already have the local version in a variable, here’s how you can get the version from the latest Link:

$ curl -sI https://latest.mattermost.com/mattermost-team-linux | sed -n 's!^Location.*/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/mattermost-.*!\1\2\3!p'
720

With this format, you could then just compare the numbers to know if you need to download and update the software.
If you’re using the Enterprise edition, there will be Debian packages soon, so it then boils down to apt update && apt install mattermost, if you like.

1 Like

Thank you @agriesser for writing the URL parsing logic ! :+1:

Looks good, unfortunately doesn’t work on Debian10, but it’s because of the regex,… Location is lowercase for me here, so the correct string ist for me:

curl -sI https://latest.mattermost.com/mattermost-team-linux | sed -n 's!^location.*/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/mattermost-.*!\1\2\3!p'

Thanks so far! I can monitor now updates much better :wink:

I’ve never seen a curl version where Location was case sensitive - could it be that you’re using a locale setting that translated it to a lowercase location? The version working for both options would be:

curl -sI https://latest.mattermost.com/mattermost-team-linux | sed -n 's!^location.*/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/mattermost-.*!\1\2\3!ip'

But glad to hear that this helped you achieving your goal :slight_smile:

Actually its a usual Debian10 installation without any specific (manual) changes!?
The first example you wrote just executed and exited then. So I looked into curl output and found that “issue”. Have a look for yourself:

However, thanks for your support, it helps a lot! :heartpulse: