Question about build.getAction()

15 views
Skip to first unread message

Mads Nielsen

unread,
Dec 3, 2014, 6:30:45 AM12/3/14
to jenkin...@googlegroups.com
I have a question, how are Actions attributed to builds sorted? 

for example i am working with the Multiple-SCM's plugin which can add multiple GitSCM actions. 

BuildData gitBuildData = build.getAction(BuildData.class);

'Gets the action (first instance to be found) of a specified type that contributed to this build.'

So...for each job run i only want the newest (or the repository that triggered the build) .

But for that to work, the actions would need to be sorted by date created in Descending order.





--
____________________________________________________________
Mads Nielsen
Consultant
m...@praqma.net
+45 50 98 18 09
Skype: inkspot
Praqma
www.praqma.com
Allerød Stationsvej 4
DK-3450 Allerød
+45 36 77 27 62

James Nord

unread,
Dec 3, 2014, 7:00:28 AM12/3/14
to jenkin...@googlegroups.com
Hi Mads,

They are in the order that they where added to the build (via addAction(...) ) - but this is an implementation detail that is not in the contract and there is nothing stopping any arbitrary code from sorting or otherwise modifying the order of the list.

see https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/model/Actionable.java

If you need a specific BuildData - I would suggest you use
build.getActions(BuildData.class) and then use logic in your plugin to get the one you are most interested in.

Regards

/James




On 03/12/2014 11:30, Mads Nielsen wrote:
Reply all
Reply to author
Forward
0 new messages