Bug - Not A Bug Jenkins API ?tree= stopped working

taltamir

Member
there seems to be a problem with the jenkins API. if I use a browser to access and compare
Code:
https://ci.kolmafia.us/job/Kolmafia/api/json
to
Code:
https://ci.kolmafia.us/job/Kolmafia/api/json?tree=builds
in the former if I find builds and look at them they each have _class, number and url
in the latter the builds only have _class and nothing else
this did not used to be the case, used to be you would get all 3 when using the ?tree= command. but some time ago this bit of the API broke.
 

MCroft

Developer
Staff member
I know there was an update a few months ago. Perhaps the format changed?

https://ci.kolmafia.us/job/Kolmafia/api/json?tree=builds[number,status,timestamp,id,result]

JSON:
{
   "_class":"hudson.model.FreeStyleProject",
   "builds":[
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"188",
         "number":188,
         "result":"SUCCESS",
         "timestamp":1617698769853
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"187",
         "number":187,
         "result":"SUCCESS",
         "timestamp":1617698169827
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"186",
         "number":186,
         "result":"SUCCESS",
         "timestamp":1617487571147
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"185",
         "number":185,
         "result":"SUCCESS",
         "timestamp":1617368471204
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"184",
         "number":184,
         "result":"SUCCESS",
         "timestamp":1617321669264
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"183",
         "number":183,
         "result":"SUCCESS",
         "timestamp":1617311468845
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"182",
         "number":182,
         "result":"SUCCESS",
         "timestamp":1617307868693
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"181",
         "number":181,
         "result":"SUCCESS",
         "timestamp":1616689268001
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"180",
         "number":180,
         "result":"SUCCESS",
         "timestamp":1616688667974
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"179",
         "number":179,
         "result":"SUCCESS",
         "timestamp":1616171466638
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"178",
         "number":178,
         "result":"SUCCESS",
         "timestamp":1615979768781
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"177",
         "number":177,
         "result":"SUCCESS",
         "timestamp":1615903570613
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"176",
         "number":176,
         "result":"SUCCESS",
         "timestamp":1615842367993
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"175",
         "number":175,
         "result":"SUCCESS",
         "timestamp":1615304168096
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"174",
         "number":174,
         "result":"SUCCESS",
         "timestamp":1615303568067
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"173",
         "number":173,
         "result":"SUCCESS",
         "timestamp":1615303268049
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"172",
         "number":172,
         "result":"SUCCESS",
         "timestamp":1615296372743
      },
      {
         "_class":"hudson.model.FreeStyleBuild",
         "id":"171",
         "number":171,
         "result":"SUCCESS",
         "timestamp":1615295767711
      }
   ]
}
 

taltamir

Member
oh, thank you. is there a mafia version option?
I also noticed that [url,artifacts[relativePath]] work as well.
 

MCroft

Developer
Staff member
curl -v -g https://ci.kolmafia.us/job/Kolmafia/api/json?tree=builds[number,status,timestamp,result,changeSet[items[commitId,revision,user,msg]]]

Not sure where this is documented, but I found out how to get it. :)

JSON:
{
         "_class":"hudson.model.FreeStyleBuild",
         "number":188,
         "result":"SUCCESS",
         "timestamp":1617698769853,
         "changeSet":{
            "_class":"hudson.scm.SubversionChangeLogSet",
            "items":[
               {
                  "_class":"hudson.scm.SubversionChangeLogSet$LogEntry",
                  "commitId":"20675",
                  "msg":"Fix some small robo bugs",
                  "revision":20675,
                  "user":"innerdreams"
               }
            ]
         }
      }
 

MCroft

Developer
Staff member
found the docs.

send a [*] for a full list. You'll have to iterate down to changeSet and items.
 
Top