2

How to get programatically the version number designated as the current LTS release of Jenkins, one of a list of weekly release numbers?

The Jenkins download page has text to indicate the current version designated as LTS (e.g., 2.46.2). To download the current Jenkins LTS release binary for Ubuntu, there are two choices:

  • distro-specific packages, which contain the version in their name so as to not be ambiguous.
  • generic war file, which does not contain version number to permit a constant download target that presumably is guaranteed to link to the current version as it changes over time.

I am looking for a means of programatically getting the version number, so that it can be used to:

  • Check the current version to detect updates
  • Describe the generic war file
  • Complete a file name to retrieve that contains the version number

I am hoping there is a single file that contains the authoritative version value somewhere on the Jenkins.io site, that can be queried via cURL or some such.

Codex24
  • 323
  • 1
  • 5
  • 14

3 Answers3

8

The jenkins update center [1] provides the latest release numbers

So, a simple curl -Ls https://updates.jenkins.io/stable/latestCore.txt should do the trick of retrieving the latest LTS version number.

[1] https://updates.jenkins.io/

Torsten Dreyer
  • 116
  • 1
  • 4
  • This should be the accepted answer. The currently accepted answer relies on a specific HTML implementation in order for its various pipes and sed to work. This instead goes to the simplest source. – Kerr Jul 16 '21 at 14:10
  • Checked and Accepted, as preferable to previous solution. – Codex24 Jul 20 '23 at 13:42
2

At the time of writing this message you can find the stable releases under this url

http://mirrors.jenkins.io/war-stable/

Something like this can give you the version and a link to the WAR file

LATEST_JENKINS_LTS_VERSION=$(curl -s http://mirrors.jenkins.io/war-stable/ | grep DIR | tail -n2 | head -n1 | sed 's/^.*href="//; s/\/".*//')

LATEST_JENKINS_LTS_WAR="http://mirrors.jenkins.io/war-stable/${LATEST_JENKINS_LTS_VERSION/}/jenkins.war"

Alternatively if you just need a link to the latest jenkins war file use this url

http://mirrors.jenkins.io/war-stable/latest/jenkins.war

  • 1
    I tried to add this to your answer as an edit, but it wasn't big enough: add '-s' option to curl for less noise. LATEST_JENKINS_LTS_VERSION=$(curl -s http://... – Codex24 Aug 09 '19 at 02:40
  • Hey @Codex24, yup that is a good idea. I'll add that to the code snippet. – user1569051 Aug 23 '19 at 13:14
0

They have RSS with changelog for latest releases, each post is titled Jenkins 2.xx, so maybe you could extract this info from it.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62