Get/Detect Jenkins's version via the Jenkins API

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.