lockable-resources-plugin icon indicating copy to clipboard operation
lockable-resources-plugin copied to clipboard

Is there any API documentation on what is supported? Can this be used from command line outside of jenkins?

Open vishnugovind opened this issue 1 year ago • 10 comments

Describe your use-case which is not covered by existing documentation.

I cant find any documentation on what APIs are supported to access Jenkins Lockable Resources from outside of the Jenkins environment.

The overview part seems a little confusing as well since the Jenkins deployment with the lockable resources page does not specify the options mentioned here overview page

Can this be triggered using a call to cURL or wget etc. The python library to use this also seem pretty old. pip module

Reference any relevant documentation, other materials or issues/pull requests that can be used for inspiration.

sample api

Are you interested in contributing to the documentation?

I am very open to contributing to documenting this further.

vishnugovind avatar Jan 25 '24 14:01 vishnugovind

Hi. The documentation should be improved. There is no discussion. But can you pls tell me, why you need to access lockable-resources from outside? Maybe we should provide some nice solutions as well.

About the pip plugin. I see it first time, it is not supported from this scope. But it does not mean, we can not. Let me check, how it works

mPokornyETM avatar Jan 31 '24 07:01 mPokornyETM

Hi. The documentation should be improved. There is no discussion. But can you pls tell me, why you need to access lockable-resources from outside? Maybe we should provide some nice solutions as well.

About the pip plugin. I see it first time, it is not supported from this scope. But it does not mean, we can not. Let me check, how it works

I am trying to control access to a set of resources (devices) that is needed as part of CI. But the resources need to be shared between the Jenkins, GitHub Actions, GitLab and bunch other CI/CD tools.

the jenkins-lockable-resources pip module works well with lockable-resources plugin up to version 2.18 and any version after that including 1069.xxxx....1228.xxx... or 1232.xxx does not work when I tested it https://pypi.org/project/jenkins-lockable-resources/

vishnugovind avatar Jan 31 '24 19:01 vishnugovind

I try to google "pip install jenkins-lockable-resources" and I am scared how many "solutions" are on the google available. Most of the are too old, with syntax failures or leads to inconsistent state of resources or just breaks because of concurrent modifications in multi thread Java projects. What ever. this shall works

https://marslo.github.io/ibook/jenkins/plugins/lockable-resource.html#by-cli

@vishnugovind cany ou try it pls and confirm that. In that case I will add it into official documentation here

mPokornyETM avatar Jan 31 '24 21:01 mPokornyETM

and about the pip plugin. When I understand it corectly it just load the page, parse the content and try to "click" on reserve action button. I think we can skip the discussion if it was good idea ;-) Something like that is not maintanable, because the html pages my changed in every plugin or / and jenkins-core release. But I think the current API

reserve?resource=${resource}

shall be enough for your GitLab GitHub actions. Please be free to share your solution with this community. It might be helpfull no notice your git-hub action here When you provide some extern solution and it looks good, I will "promote" it also here and support that way too (backward compatibility ...) because it is really good idea. When you need some more actions or something like "reserved-reason" or property "reserved-by-API" feel free to inform me (here in this issue) This might be nice project / solution and win-win situation in many CI/CD tools.

mPokornyETM avatar Jan 31 '24 21:01 mPokornyETM

Hi!

I love this plugin and I use it a lot. I'm currently implementing a python wrapper that I could make available as open source software if people are interested. Currently, I'm basically just wrapping the two available API methods reserve and unreserve but this is just a small subset of the features that this plugin provides. I'd love see API endpoints such as reserve?label=...&quantity&....

One big question there is how to deal with queues, i.e. when you make an API request for a lockable resource that is already locked. The options I currently see are

  1. Re-call the reserve endpoint again and again until the resource is available.
  2. Return a queue ID that can be checked for.
  3. Provide a callback URL but this would require the client to be accessible from the Jenkins which isn't a good idea in my opinion.

Any thoughts or comments on these ideas? :blush:

g3n35i5 avatar Jul 02 '24 15:07 g3n35i5

I thik, we shall not changed the API point 'reserve' It will be better to use something like

lock?label=...&quantity&... lock?resource=${resource}

with a reason as mandatory parameter (otherwise you will lost the overwiew who and why has locked the resource)

the respond shall be then: { state : 'locked | queued' queueId: 'null | UUID' cause : null | Human readeable text, why the resource can not be locked (reserved, locked ...) }

mPokornyETM avatar Jul 03 '24 13:07 mPokornyETM

@mPokornyETM I don't think I have enough Jenkins Plugin knowledge yet to implement this here. Are you willing to implement the Plugin part and I contribute the Python part? :blush:

g3n35i5 avatar Jul 03 '24 16:07 g3n35i5

@mPokornyETM I don't think I have enough Jenkins Plugin knowledge yet to implement this here. Are you willing to implement the Plugin part and I contribute the Python part? 😊

get in contact with me on gitter: @mpokornyetm-612cc2bd6da0373984845411:gitter.im , please

mPokornyETM avatar Jul 04 '24 11:07 mPokornyETM

I wasn't aware that there already seems to be a pypi package for this:

https://pypi.org/project/jenkins-lockable-resources/ https://gitlab.com/alexandre-perrin1/jenkins-lockable-resources

Hasn't been updated since 2021 but maybe it still works (haven't checked it, yet)

g3n35i5 avatar Jul 08 '24 09:07 g3n35i5

I wasn't aware that there already seems to be a pypi package for this:

https://pypi.org/project/jenkins-lockable-resources/ https://gitlab.com/alexandre-perrin1/jenkins-lockable-resources

Hasn't been updated since 2021 but maybe it still works (haven't checked it, yet)

I will be supprised, when ot works ;-). But feel free to check / fix it

mPokornyETM avatar Jul 08 '24 09:07 mPokornyETM