Get Jenkins version via java -jar jenkins.war --version without spam output

Since Jenkins 1.649, the --version flag causes the version to be printed out directly without any of the extraneous information:

$ wget -q http://mirrors.jenkins.io/war/1.649/jenkins.war \
      && java -jar jenkins.war --version
1.649

(original answer, pre-Jenkins 1.649)

As part of the WAR packaging process, the Jenkins version is written to the manifest, which is where the --version flag gets its answer from.

So while it may not be particularly pretty, this should be stable:

unzip -c /usr/share/jenkins/jenkins.war META-INF/MANIFEST.MF \
  | egrep ^Jenkins-Version: | awk '{print $2}' 

(assuming the availability of unzip and friends)


Should this help ( on linux) :

head -5  /var/lib/jenkins/config.xml| grep -oP '(?<=<version>).*?(?=</version>)'

Jenkins version can be easily checked from the config.xml file.

  1. Navigate to Jenkins Folder location in the server.
  2. Search for config.xml file in it. Mostly it will be just directly inside Jenkins folder
  3. type command head -10 config.xml
  4. It should be in the 7th Line - <version>2.176.2</version>