0

i asked this question how do i get the latest build in jenkns with a specified parameter, and the solutions is

http://localhost:8080/job/MyJenkinsJob/api/xml?tree=builds[actions[parameters[value]],number]&xpath=//build[action[parameter[value="MyParameterValue"]]]/number&wrapper=list

however this would return multiple build numbers, but i only want the latest (one build number only)

<list><number>49</number><number>48</number></list>

I tried several variation with xpath and it didnt work

Community
  • 1
  • 1
cakester
  • 421
  • 4
  • 15

1 Answers1

0

Does XPath: Select first element with a specific attribute help at all?

So:

http://localhost:8080/job/MyJenkinsJob/api/xml?tree=builds[actions[parameters[value]],number]&xpath=(//build[action[parameter[value="MyParameterValue"]]])[0]/number&wrapper=list 

Or perhaps the brackets need to be elsewhere

jedifans
  • 2,287
  • 1
  • 13
  • 9
  • is the return values sorted by default? – cakester Aug 23 '16 at 20:19
  • From your example, yes. Perhaps not though, you'll need to test or dig into Jenkins code :) . If you are concerned, processing the XML, like chenchuk says, is probably the best way. – jedifans Aug 23 '16 at 20:22