For version of the Get/Detect Jenkins, the following page (the Jenkins Remote Access API) describes:
Https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
Detecting Jenkins version (detects Jenkins's version)
To check the version of Jenkins, load the top page (or, as of 1.483, any .../api/* page too) and check for the X-jenkins R Esponse header.
This contains the version number of the Jenkins, like "1.404" This is also a good a-to-check if a URL is a Jenkins URL.
Using the browser for Chrome, view the response header method in Chrome as follows:
1, press F12, Pop-up dialog box, press Network option;
2, click the URL/jenkins/api/python, and then click Header/response headers on it.
The example for Jenkins version using Python is as follows:
Import Requestsjenkins_python_api_url = "Http://localhost:8080/jenkins/api/python" response = Requests.post (jenkins_ Python_api_url) Print response.headers.get (' x-jenkins ')
The results of the operation are as follows:
1.592
Note: Get the version of Jenkins without regard to the authentication situation (you can get the version of Jenkins, whether or not you need authentication)
At the same time, by looking up the relevant source of Jenkins, we can know that the "x-jenkins" stored in the Responseheader message header is jenkins.version:
private void Setheaders (Staplerresponse rsp) {rsp.setheader ("X-jenkins", jenkins.version); Rsp.setheader (" X-jenkins-session ", Jenkins.session_hash);}
Get/Detect Jenkins's version via the Jenkins API