Plugin Development: expansion of Lockable Resources Plugin?

110 views
Skip to first unread message

Kevin Werner

unread,
May 18, 2018, 12:22:21 PM5/18/18
to Jenkins Developers
Hi,

The current Lockable Resources Plugin has reservation for external resources and the ability to lock (and wait for availability to lock) them during a build pipeline.  This is very helpful functionality that I'm already using minimally in our test pipelines.  For the plugin to really be useful for me though, I need some additional functionality:

1.  The ability to reserve, unreserve and query the current reservations and available resources through a REST API rather than the GUI; I have a couple external tools that I would like to integrate with.  I need to especially be able to query the resources that are currently reserved to a jenkins user.  The main utility is that we have CI, manual and automated (outside CI) test runs and I want to integrate the reservation system for all, if possible.  For instance, before a manual run starts, I want to make sure that the resources are actually reserved by the developer. 
2.  I would like to possibly add some additional data to the lockable resources as well.  This is a longer-term goal as I could abuse the description field in the short-term and use it for my own purposes.  I'm hoping to be able to add JSON metadata about the resource that is useful for the external tools to know (ex. PDU information so I can power it on/off during a pipeline). 
3.  I would also like to add an optional reservation "tag" when reserving that can help create sub-groups of reservations (ex.  Joe reserves two separate resources, but he wants to use each for two different test runs that are running simultaneously so the external test tool needs to query not only what he has reserved but choose the correct resource for each test run)

Is there any functionality like this that exists already that I don't know about?  I hate reinventing the wheel.

If not, I'm not currently a Jenkins plugin dev, but I have a Java/Groovy background and I'm happy to jump in and start contributing.  I'm assuming I can modify and add to the current Lockable Resources Plugin?  I'm happy to coordinate with other devs with this work.

For now, I'm going to start poking around getting a dev environment setup for myself and start playing around with making my own plugin.

Any feedback or help is welcome.  Thanks in advance!

kddubb

Jesse Glick

unread,
May 18, 2018, 12:55:37 PM5/18/18
to Jenkins Dev
On Fri, May 18, 2018 at 12:15 PM, Kevin Werner <kdd...@gmail.com> wrote:
> Is there any functionality like this that exists already that I don't know
> about?

Look through

https://github.com/jenkinsci/lockable-resources-plugin/pulls

Probably best to discuss any major plans with @abayer & @amuniz, who
seem to have been active recently merging PRs. As a rule, PRs are most
likely to get traction if they are reasonably small (reviewers have
very limited time to grasp what you are doing), solving a single
specific problem, with thorough test coverage, and no compatibility
impact.

Kevin Werner

unread,
May 18, 2018, 1:53:35 PM5/18/18
to Jenkins Developers
Awesome I'll take a look through those.

Steven F

unread,
May 18, 2018, 2:00:27 PM5/18/18
to Jenkins Developers
There's definitely an open PR for the 2nd feature which I am patiently waiting for

Kevin Werner

unread,
May 18, 2018, 5:11:41 PM5/18/18
to Jenkins Developers
btw, I haven't had to use the Remote Access API much, but it seems like #1 on my list should be implemented by adding a .../api to the /lockable-resources/ URL?

https://wiki.jenkins.io/display/JENKINS/Remote+access+API

Any suggestions on good plugin examples to use?  I'm sure I can figure it out for myself, but since I'm newer to this I'm sure having a pointer in the right direction from those that know would be helpful!

Thanks in advance,

kddubb

Jesse Glick

unread,
May 18, 2018, 5:39:39 PM5/18/18
to Jenkins Dev
On Fri, May 18, 2018 at 5:11 PM, Kevin Werner <kdd...@gmail.com> wrote:
> it seems like #1
> on my list should be implemented by adding a .../api to the
> /lockable-resources/ URL?

Perhaps for “querying current reservations”, but Stapler export API
(`hudson.model.Api`, what you linked to) is read-only. For general
operations you need to implement Stapler web methods in various
patterns.

> Any suggestions on good plugin examples to use?

Some plugins implement RESTish APIs, some implement CLI commands, some
implement both, and the quality is quite variable I am afraid. Jenkins
core implements plenty of RESTish APIs; sometimes they are documented
in `_api.jelly` files, but usually they are not. You can find APIs
very roughly by searching for usages of `StaplerRequest`,
`StaplerResponse`, `HttpResponse`, and a few other things.

http://stapler.kohsuke.org/reference.html

Kevin Werner

unread,
May 18, 2018, 5:42:16 PM5/18/18
to Jenkins Developers
Thanks Jesse, that should get me started.  I appreciate the pointers.  :)

kddubb

Antonio Muñiz

unread,
May 22, 2018, 4:49:40 AM5/22/18
to jenkin...@googlegroups.com
Hey! All the features you are proposing make sense to me.
The one about "additional data on resources" would be covered by https://github.com/jenkinsci/lockable-resources-plugin/pull/20 maybe... unfortunately that's a big one that I did not have time to review yet.

Feel free to file JIRA issues for the others and even work on them and contribute if you feel comfortable with it.


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Kevin Werner

unread,
May 23, 2018, 10:35:30 AM5/23/18
to Jenkins Developers
Awesome, thanks!  For now, I'm learning and getting things working.  I was able to pretty simply turn on the read-only API and add the resources which was very helpful in the short-term.  I will submit pull requests back when I get things in a state that can be submitted.  I'm trying to keep the various functionality on separate branches at first so you can approve and accept things individually.

kddubb
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages