2

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"
    }
    
8
  • 1
    in case there is no API maybe parse somehow from here? archive.apache.org/dist/tomcat/tomcat-8 Feb 4 '18 at 15:35
  • Thank you @PeterMuryshkin That could be an option indeed. I will do some tests.
    – 030
    Feb 4 '18 at 15:36
  • There's a generic GitHub Release REST API: developer.github.com/v3/repos/releases But I didn't use it, no clue if it can be used for your case. Worth a try maybe. Feb 4 '18 at 17:45
  • @DanCornilescu Thank you for the suggestion. I have added the output to the question.
    – 030
    Feb 4 '18 at 17:54
  • 1
    I would like to always create a new package and later decide whether we will use it.
    – 030
    Feb 4 '18 at 19:59
2

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/

1

Using Powershell's Invoke-WebRequest cmdlet:

$Links=$(Invoke-WebRequest -Uri 'https://tomcat.apache.org/download-80.cgi' | Select-Object -ExpandProperty Links)
$($Links | Where-Object -Property href -Match '#8.5.[0-9]+').href.substring(1)

Returns:

8.5.54

This command works on Windows/Linux/MACOS

0

Indeed, releases don't appear to have been registered on GitHub, the releases list returned by the REST is empty, most likely explaining the 404 returned for releases/latest:

curl -i https://api.github.com/repos/apache/tomcat/releases
HTTP/1.1 200 OK
...

[

]

There are however tags registered, including some apparently mapping to the 9.0.X versions:

curl -i https://api.github.com/repos/apache/tomcat/tags | & grep '"name"'
    "name": "TONCAT_9_0_0_M23",
    "name": "TOMCAT_9_0_5",
    "name": "TOMCAT_9_0_4",
    "name": "TOMCAT_9_0_3",
    "name": "TOMCAT_9_0_2",
    "name": "TOMCAT_9_0_1",
    "name": "TOMCAT_9_0_0",
    "name": "TOMCAT_9_0_0_m27",
    ...
    "name": "TOMCAT_9_0_0_M6",

Example of a tag info, which might be of use:

  {
    "name": "TOMCAT_9_0_5",
    "zipball_url": "https://api.github.com/repos/apache/tomcat/zipball/TOMCAT_9_0_5",
    "tarball_url": "https://api.github.com/repos/apache/tomcat/tarball/TOMCAT_9_0_5",
    "commit": {
      "sha": "e0fdefed3d9e2a4dbfd36a5a79e75e0eadaa201d",
      "url": "https://api.github.com/repos/apache/tomcat/commits/e0fdefed3d9e2a4dbfd36a5a79e75e0eadaa201d"
    }
  },

But the info doesn't appear consistent with the info on the Tomcat homepage you referenced:

  • the 9.0.5 version isn't listed as released on the homepage
  • only 9.X versions show up, older ones don't

So I'm not sure if this is helpful.

0

Today 8.5.49 was returned as a 'stable' version, while it should have been 8.5.47. The following:

URL=https://tomcat.apache.org/download-80.cgi
curl -s $URL  | grep "8\.5\.[0-9]\+</a>" | sed -e 's|.*>\(.*\)<.*|\1|g'

returns:

8.5.47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.