Determine if given job is currently running using Hudson/Jenkins API

前端 未结 5 949
忘掉有多难
忘掉有多难 2020-12-29 05:24

Is there an API to determine whether a given job is currently running or not?

Ideally, I\'d also like to be able to determine its estimated % complete and get the de

5条回答
  •  猫巷女王i
    2020-12-29 06:03

    As stated on the /api page of your build (chapter "Accessing Progressive Console Output"), you can poll the console output with a GET request by calling /lastBuild/logText/progressiveText. To quote the API doc:

    If the response also contains the X-More-Data: true header, the server is indicating that the build is in progress

    And there you go. You can test this behaviour by simply calling the respective URL in your browser and then inspecting the response headers with your browser's developer tools (usually accessed by pressing F12). In Firefox, the respective tab is called "network analysis" (assuming my translation is correct, my browser is not set to English). In Chrome, navigate to the "Network" tab.

    This answer is based on Jenkins version 2.176.3.

提交回复
热议问题