Jenkins selected filtering values in parameter objects

594 views
Skip to first unread message

Chennai Cheetah

unread,
Oct 27, 2022, 9:40:24 AM10/27/22
to Jenkins Users

How do I get only selected jenkins information from the API response.

I tried with the below url

https://myorg.com/job/architecture-shared-services/job/myrepo/api/json?tree=builds[number,url,result,actions[parameters[name,value]]]&pretty=true{0,2}

and it returned almost all data present in the build details.

How do I filter rulesetid,branch details only from the parameter object, while rest of the parameters are not required in the response.

Below is my API Response


{ "_class": "org.jenkinsci.plugins.workflow.job.WorkflowJob", "builds": [ { "_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "actions": [ { "_class": "hudson.model.ParametersAction", "parameters": [ { "_class": "hudson.model.TextParameterValue", "name": "rulesetid", "value": "62e11268999630f4a49295c4" }, { "_class": "hudson.model.TextParameterValue", "name": "environment", "value": "sit" }, { "_class": "hudson.model.TextParameterValue", "name": "tranid", "value": "1234" } ] }, { "_class": "org.jenkinsci.plugins.workflow.job.views.FlowGraphAction" } ], "number": 243, "result": "SUCCESS", "url": "https://jenkins.myrepodigital.com/job/architecture-shared-services/job/myrepoio-io-rmaappetite_sit/243/" }, { "_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun", "actions": [ { "_class": "hudson.model.ParametersAction", "parameters": [ { "_class": "hudson.model.TextParameterValue", "name": "branch", "value": "sit" }, { "_class": "hudson.model.TextParameterValue", "name": "environment", "value": "sit" }, { "_class": "hudson.model.TextParameterValue", "name": "tranid", "value": "12345" } ] }, { "_class": "org.jenkinsci.plugins.workflow.job.views.FlowGraphAction" } ], "number": 243, "result": "SUCCESS", "url": "https://jenkins.myrepodigital.com/job/architecture-shared-services/job/myrepoio-io-rmaappetite_sit/243/" } ] }

Daniel Beck

unread,
Oct 27, 2022, 11:06:01 AM10/27/22
to jenkins...@googlegroups.com
On Thu, Oct 27, 2022 at 3:39 PM Chennai Cheetah <chennai...@gmail.com> wrote:

How do I get only selected jenkins information from the API response.

How do I filter rulesetid,branch details only from the parameter object, while rest of the parameters are not required in the response.

Work with the XML API output and use an XPath expression, or process the JSON API responses using a tool like jq.

Chennai Cheetah

unread,
Oct 28, 2022, 1:36:57 AM10/28/22
to Jenkins Users
hi db,

I tried with xml api  below is my url


It returns 

<builds>
<parameter _class="hudson.model.TextParameterValue">
<name>rulesetid</name>
<value>635aa36a3f80310ae7e36c87</value>
</parameter>
</builds>

How do I get number, url, result tags in the response?

Mateusz Pawełek

unread,
Feb 9, 2023, 4:34:00 PM2/9/23
to Jenkins Users
Reply all
Reply to author
Forward
0 new messages