HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to get the latest Tomcat version?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
tomcatlatesttheversiongethow

Problem

If one checks the Tomcat homepage then one could see some versions, but not only the latest. Off course I could parse the website and find the version, but I am looking for a Tomcat API that shows the latest version to prevent that I have to create a script that is error prone.

Why?

I would like to automate the update of our internal tomcat packages. At the moment someone is checking the latest version and create the debian package manually, but I want to see that that is automated.

What has been tried?

  • The github mirror does not show the latest version https://github.com/apache/tomcat/releases



  • The official tomcat html could be parsed, but that does not seem to be the easiest solution



-
curl https://api.github.com/repos/apache/tomcat/releases/latest returns:

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/repos/releases/#get-the-latest-release"
}

Solution

Get the latest version of Tomcat:

$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=1' | jq -r .[].name
9.0.20


Get the latest version of Tomcat 9:

$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=100' | jq -r '.[] | .name' | sort -V | grep ^9 | tail -n 1
9.0.20


Get the latest version of Tomcat 8.5:

$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=100' | jq -r '.[] | .name' | sort -V | grep ^8.5 | tail -n 1
8.5.41


Get the latest version of Tomcat 7:

$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=100' | jq -r '.[] | .name' | sort -V | grep ^7 | tail -n 1
7.0.94


These all currently match the latest versions listed at http://tomcat.apache.org/

Code Snippets

$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=1' | jq -r .[].name
9.0.20
$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=100' | jq -r '.[] | .name' | sort -V | grep ^9 | tail -n 1
9.0.20
$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=100' | jq -r '.[] | .name' | sort -V | grep ^8.5 | tail -n 1
8.5.41
$ curl -s 'https://api.github.com/repos/apache/tomcat/tags?per_page=100' | jq -r '.[] | .name' | sort -V | grep ^7 | tail -n 1
7.0.94

Context

StackExchange DevOps Q#3262, answer score: 4

Revisions (0)

No revisions yet.