Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vishnugovind opened this issue Jan 25, 2024 · 10 comments
Labels
Clarification needed Additional clarification needed documentation

Comments

@vishnugovind
Copy link

vishnugovind commented Jan 25, 2024

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.

@mPokornyETM
Copy link
Contributor

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 mPokornyETM added the Clarification needed Additional clarification needed label Jan 31, 2024
@mPokornyETM mPokornyETM added this to the Improve our documentation milestone Jan 31, 2024
@vishnugovind
Copy link
Author

vishnugovind commented Jan 31, 2024

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/

@mPokornyETM
Copy link
Contributor

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
Copy link
Contributor

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.

@g3n35i5
Copy link
Contributor

g3n35i5 commented Jul 2, 2024

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? 😊

@mPokornyETM
Copy link
Contributor

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 ...)
}

@g3n35i5
Copy link
Contributor

g3n35i5 commented Jul 3, 2024

@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? 😊

@mPokornyETM
Copy link
Contributor

@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

@g3n35i5
Copy link
Contributor

g3n35i5 commented Jul 8, 2024

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)

@mPokornyETM
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clarification needed Additional clarification needed documentation
Projects
None yet
Development

No branches or pull requests

3 participants