Retrieve parameter from a Jenkins REST query

后端 未结 3 747
日久生厌
日久生厌 2021-02-15 00:03


The following REST query will return parameters of the last successful build of a job: https://localhost/job/test1/lastSuccessfulBuild/api/json
I\'d be interested to

3条回答
  •  萌比男神i
    2021-02-15 01:07

    Short answer: No.

    Easiest way to programmatically access any attribute exposed via the JSON API is to take the JSON from one of Jenkins supported JSON APIs (in your case: https://localhost/job//lastSuccessfulBuild/api/json)

    1. Copy the resultant JSON into http://json2csharp.com
    2. Generate the corresponding C# code. Don't forget to create a meaningful name for top level class.
    3. Call RestAPI programmatically from C# using RestSharp.
    4. Deserialise the json to the C# class you defined in 2 above.

    Wammo, you have access to the entire object tree and all its values.

    I used this approach to write an MVC5 ASP.NET site I called "BuildDashboard" to provide all the information a development team could want and answered every question they had.

提交回复
热议问题