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

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

<p>returns:</p>

<pre><code>8.5.47
</code></pre>

CC BY-SA 4.0
2019-11-18T10:48:08.537Z
2019-11-18T10:48:08.537Z
030
<p>I created a script to download, unzip, install tomcat 9.0.latest</p>
<p>sample.war and deploy</p>
<p>curl &lt;&gt;/sample/</p>
<p>Here is the information that I assume you're wanting, below:</p>
<pre><code># PATHS #
# DO NOT END DIRECTORY PATHS WITH \ PLEASE!
$WORKING_DRIVE=&quot;C:&quot;
$DOWNLOADS_DIRECTORY=&quot;${WORKING_DRIVE}\DOWNLOADS&quot;
$TOMCAT_VERSION_NUMBER=&quot;9&quot;
$TOMCAT_SUB_VERSION_NUMBER=&quot;0&quot;
$TOMCAT_DIRECTORY=&quot;${WORKING_DRIVE}\Tomcat${TOMCAT_VERSION_NUMBER}${TOMCAT_SUB_VERSION_NUMBER}&quot;


# Script will automatically download the tomcat file if one is not found in folder
$Links=$(Invoke-WebRequest -Uri &quot;https://tomcat.apache.org/download-${TOMCAT_VERSION_NUMBER}${TOMCAT_SUB_VERSION_NUMBER}.cgi&quot; | Select-Object -ExpandProperty Links)
$TOMCAT9_LATEST_VERSION=$($Links | Where-Object -Property href -Match &quot;#${TOMCAT_VERSION_NUMBER}.${TOMCAT_SUB_VERSION_NUMBER}.[0-9]+&quot;).href.substring(1)
$TOMCAT9_LATEST_ZIP_FILE=&quot;apache-tomcat-${TOMCAT9_LATEST_VERSION}-windows-x64.zip&quot;
$TOMCAT_DOWNLOAD_URL=&quot;https://dlcdn.apache.org/tomcat/tomcat-${TOMCAT_VERSION_NUMBER}/v${TOMCAT9_LATEST_VERSION}/bin/${TOMCAT9_LATEST_ZIP_FILE}&quot;
Write-Output &quot;Downloading latest Tomcat ${TOMCAT9_LATEST_VERSION} file:`n${TOMCAT_DOWNLOAD_URL}&quot;
Invoke-WebRequest -URI ${TOMCAT_DOWNLOAD_URL} -OutFile &quot;${DOWNLOADS_DIRECTORY}\${TOMCAT9_LATEST_ZIP_FILE}&quot;

# https://tomcat.apache.org/download-90.cgi
# https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74-windows-x64.zip
# ^ 12MB
</code></pre>
<p>#################################</p>
<h1>POWERSHELL OUTPUT:</h1>
<p>Downloading latest Tomcat 9.0.74 file:
<a href="https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74-windows-x64.zip" rel="nofollow noreferrer">https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74-windows-x64.zip</a></p>

CC BY-SA 4.0
2023-04-22T15:58:52.550Z
2023-04-22T15:59:54.023Z
2023-04-22T15:59:54.023Z
Scott Baker
<p>Using Powershell's <code>Invoke-WebRequest</code> cmdlet:</p>

<pre><code>$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)
</code></pre>

<p>Returns:</p>

<pre><code>8.5.54
</code></pre>

<p>This command works on Windows/Linux/MACOS</p>

CC BY-SA 4.0
2020-04-11T03:09:18.593Z
2020-04-11T03:51:20.103Z
2020-04-11T03:51:20.103Z
Hames
<p>Indeed, releases don't appear to have been registered on GitHub, the <code>releases</code> list returned by the REST is empty, most likely explaining the 404 returned for <code>releases/latest</code>:</p>

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

[

]
</code></pre>

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

<pre><code>curl -i https://api.github.com/repos/apache/tomcat/tags | &amp; 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",
</code></pre>

<p>Example of a tag info, which <em>might</em> be of use:</p>

<pre><code>  {
    "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"
    }
  },
</code></pre>

<p>But the info doesn't appear consistent with the info on the Tomcat 
homepage you referenced: </p>

<ul>
<li>the <code>9.0.5</code> version isn't listed as released on the homepage</li>
<li>only <code>9.X</code> versions show up, older ones don't</li>
</ul>

<p>So I'm not sure if this is helpful.</p>

CC BY-SA 3.0
2018-02-08T00:49:19.810Z
2018-02-08T00:49:19.810Z
Dan Cornilescu
<p>Get the latest version of Tomcat:</p>

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

<p>Get the latest version of Tomcat 9:</p>

<pre><code>$ 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
</code></pre>

<p>Get the latest version of Tomcat 8.5:</p>

<pre><code>$ 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
</code></pre>

<p>Get the latest version of Tomcat 7:</p>

<pre><code>$ 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
</code></pre>

<p>These all currently match the latest versions listed at <a href="http://tomcat.apache.org/" rel="nofollow noreferrer">http://tomcat.apache.org/</a></p>

CC BY-SA 4.0
2023-12-14T15:09:56.880Z
Just a note. Github limits the number of [tags pr page to 100](https://docs.github.com/en/rest/releases/releases#list-releases) and sorts them by name and tomcat has a lot of releases, thus I was able to find tomcat8.5.97 (newest) on page 3. Use the `page=` parameter to iterate.
Folkmann
CC BY-SA 4.0
2019-05-22T20:39:22.930Z
2019-05-22T20:39:22.930Z
bmaupin
<p>If one checks <a href="http://tomcat.apache.org/" rel="nofollow noreferrer">the Tomcat homepage</a> 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.</p>

<p><strong>Why?</strong></p>

<p>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.</p>

<p><strong>What has been tried?</strong></p>

<ul>
<li>The github mirror does not show the latest version <a href="https://github.com/apache/tomcat/releases" rel="nofollow noreferrer">https://github.com/apache/tomcat/releases</a></li>
<li>The official tomcat html could be parsed, but that does not seem to be the easiest solution</li>
<li><p><code>curl https://api.github.com/repos/apache/tomcat/releases/latest</code> returns:</p>

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

CC BY-SA 3.0
2018-02-04T15:35:14.123Z
in case there is no API maybe parse somehow from here? https://archive.apache.org/dist/tomcat/tomcat-8/
Ta Mu
CC BY-SA 3.0
2018-02-04T15:36:01.113Z
Thank you @PeterMuryshkin That could be an option indeed. I will do some tests.
030
CC BY-SA 3.0
2018-02-04T17:45:29.087Z
There's a generic GitHub Release REST API: https://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.
Dan Cornilescu
CC BY-SA 3.0
2018-02-04T17:54:01.600Z
@DanCornilescu Thank you for the suggestion. I have added the output to the question.
030
CC BY-SA 3.0
2018-02-04T19:49:52.050Z
Why do you always want the latest version? Wouldn't you want to read over the changelog and see if you want to upgrade, whether it will break anything, and whether there are useful new features for you?
Xiong Chiamiov
CC BY-SA 3.0
2018-02-04T19:59:34.870Z
I would like to always create a new package and later decide whether we will use it.
030
CC BY-SA 3.0
2018-02-25T18:38:41.407Z
@030 Using the GitHub rest API would be the easiest. It looks like the releases page _is_ up to date. They have `v9.0.5` listed 19 days ago. The Tomcat official page seems to have `v9.0.5` as the latest as well. So it looks like they _do_ keep the mirror up to date. I actually have code for doing this as I use it for parsing the latest version on some other projects. I could share. Is there a reason you see that the GitHub releases page won't work?
BoomShadow
CC BY-SA 3.0
2018-02-25T18:56:51.380Z
I am looking for the latest stable version. The releases page contains also unstable versions, e.g. `TOMCAT_9_0_0_m27`
030
<automation><tomcat><api>
How to get the latest Tomcat version?
030
# How to get the latest Tomcat version?

(Asked by: username_0 on 2018-02-04)

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"
}

**Tags:** automation, tomcat, api

> **Comments:**
> **username_1**: in case there is no API maybe parse somehow from here? https://archive.apache.org/dist/tomcat/tomcat-8/  
> **username_0**: Thank you @PeterMuryshkin That could be an option indeed. I will do some tests.  
> **username_2**: There's a generic GitHub Release REST API: https://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.  
> **username_0**: @DanCornilescu Thank you for the suggestion. I have added the output to the question.  
> **username_3**: Why do you always want the latest version? Wouldn't you want to read over the changelog and see if you want to upgrade, whether it will break anything, and whether there are useful new features for you?  
> **username_0**: I would like to always create a new package and later decide whether we will use it.  
> **username_4**: @username_0 Using the GitHub rest API would be the easiest. It looks like the releases page _is_ up to date. They have `v9.0.5` listed 19 days ago. The Tomcat official page seems to have `v9.0.5` as the latest as well. So it looks like they _do_ keep the mirror up to date. I actually have code for doing this as I use it for parsing the latest version on some other projects. I could share. Is there a reason you see that the GitHub releases page won't work?  
> **username_0**: I am looking for the latest stable version. The releases page contains also unstable versions, e.g. `TOMCAT_9_0_0_m27`  

---

## 5 answers

### Answer by username_7 on 2019-05-22. Score: 4 | Accepted answer

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/

> **Comments:**
> **username_8**: Just a note. Github limits the number of [tags pr page to 100](https://docs.github.com/en/rest/releases/releases#list-releases) and sorts them by name and tomcat has a lot of releases, thus I was able to find tomcat8.5.97 (newest) on page 3. Use the `page=` parameter to iterate.  

---

### Answer by username_0 on 2019-11-18. Score: 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]\+" | sed -e 's|.*>\(.*\)<.*|\1|g'

returns:
8.5.47


---

### Answer by username_5 on 2023-04-22. Score: 0

I created a script to download, unzip, install tomcat 9.0.latest
sample.war and deploy
curl <>/sample/
Here is the information that I assume you're wanting, below:
# PATHS #
# DO NOT END DIRECTORY PATHS WITH \ PLEASE!
$WORKING_DRIVE="C:"
$DOWNLOADS_DIRECTORY="${WORKING_DRIVE}\DOWNLOADS"
$TOMCAT_VERSION_NUMBER="9"
$TOMCAT_SUB_VERSION_NUMBER="0"
$TOMCAT_DIRECTORY="${WORKING_DRIVE}\Tomcat${TOMCAT_VERSION_NUMBER}${TOMCAT_SUB_VERSION_NUMBER}"


# Script will automatically download the tomcat file if one is not found in folder
$Links=$(Invoke-WebRequest -Uri "https://tomcat.apache.org/download-${TOMCAT_VERSION_NUMBER}${TOMCAT_SUB_VERSION_NUMBER}.cgi" | Select-Object -ExpandProperty Links)
$TOMCAT9_LATEST_VERSION=$($Links | Where-Object -Property href -Match "#${TOMCAT_VERSION_NUMBER}.${TOMCAT_SUB_VERSION_NUMBER}.[0-9]+").href.substring(1)
$TOMCAT9_LATEST_ZIP_FILE="apache-tomcat-${TOMCAT9_LATEST_VERSION}-windows-x64.zip"
$TOMCAT_DOWNLOAD_URL="https://dlcdn.apache.org/tomcat/tomcat-${TOMCAT_VERSION_NUMBER}/v${TOMCAT9_LATEST_VERSION}/bin/${TOMCAT9_LATEST_ZIP_FILE}"
Write-Output "Downloading latest Tomcat ${TOMCAT9_LATEST_VERSION} file:`n${TOMCAT_DOWNLOAD_URL}"
Invoke-WebRequest -URI ${TOMCAT_DOWNLOAD_URL} -OutFile "${DOWNLOADS_DIRECTORY}\${TOMCAT9_LATEST_ZIP_FILE}"

# https://tomcat.apache.org/download-90.cgi
# https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74-windows-x64.zip
# ^ 12MB

#################################
POWERSHELL OUTPUT:
Downloading latest Tomcat 9.0.74 file:
https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.74/bin/apache-tomcat-9.0.74-windows-x64.zip


---

### Answer by username_6 on 2020-04-11. Score: 0

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


---

### Answer by username_2 on 2018-02-08. Score: 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.


---

