jenkinsci / cloudevents-plugin

Cloudevents Plugin for Jenkins
https://plugins.jenkins.io/cloudevents/
MIT License
18 stars 15 forks source link

Move the plugin configuration to its own page #10

Open ShrutiC-git opened 2 years ago

ShrutiC-git commented 2 years ago

Dependencies

Feature Request

The plugin is configurable under Manage Jenkins page. However, since the plugin as a whole (as a source and as a sink) requires a good amount of configuration, it reduces readability since there already is a lot of other things to configure inside the Manage Jenkins page

This feature suggests moving the configuration from Global Configuration/Manage Jenkins to its own page. Some plugins in the Jenkins ecosystem use their own page inside Jenkins which makes the UI cleaner, and makes it easy for users to enter the info needed for the plugin's configuration. Some examples of such plugin are:

These plugins extend from the Management Link class which allows these plugins to have their own configurable page. If the CloudEvents plugin had its own configurable page, it will make configuring the plugin easier.

GouravSardana commented 2 years ago

Do we need to make a new page for this plugin. If yes then where to add that ?

Can i add this below manage Jenkins text to redirect this to a different page ? If yes, I could not find management link class which you mentioned above.

GouravSardana commented 2 years ago

Some research from my end -

  1. That plugin template is rendering from config.jelly and it is taking the jenkins global configuration. I think that i need to change.

Still i could not found that management link class

Edit - I found out the configuration file i.e cloudeventsglobalconfig

ShrutiC-git commented 2 years ago

Hi Gourav! Yes, the current global-configuration is what is visible inside 'Configure System' inside Jenkins, and the file available under CloudEventsGlobalConfig. What we want to do is change where we configure this. Great work on figuring the entire workflow! 🎉

Right now, the plugin is configurable under Configure System, and we want to move it a have its own link/icon inside Manage Jenkins. If you click on Manage Jenkins, you'll see: System Configuration, Security, Tools and Actions, Torubleshooting. We want this plugin to have a similar link, where it'll be on this page and reachable + configurable easily!

GouravSardana commented 2 years ago

Hey,

I got your point but i have few concerns in my mind -

  1. Where is that management link class which you are talking above ?
  2. I have to move the plugin under manage jenkins that is fine but i couldn't find that part where those a tags or jelly are there. Is that extending from somewhere else ?

Edit- Find out the management link hudson.model. Thanks for providing the reference of the plugin. Let me see the implementation, how I can move

Edit 2 - When i'm trying to extend the management class. It seems like other things like load() are breaking because those are extended from globalconfiguration. Is there is anything I'm missing ?

ShrutiC-git commented 2 years ago

Here's another reference document that has all the plugins which extend from this class: https://tempora-mutantur.github.io/jenkins.io/github_pages_test/doc/developer/extensions/jenkins-core/#managementlink

So once we start using ManagementLink Class, we will not need to use GlobalConfiguration anymore. Both work a bit differently: anything under global configuration uses a load/save mechanism is implemented using unmarshalling XML, which essentially means that we convert the XML into Java objects, and use it later.

For the ManagementLink, there's no default method of loading/saving, and that's because the save mechanism for anything that is under the Manage section of Jenkins should define the plugin developers want to save information. Some maybe don't necessarily want to save any information and just display status/text.

For example, consider this: https://github.com/jenkinsci/periodicbackup-plugin/blob/master/src/main/java/org/jenkinsci/plugins/periodicbackup/PeriodicBackupLink.java (PeriodicBackupPlugin) which uses a similar XML unmarshalling to save/load. So two things here:

@Override public String getUrlName() { return "periodicbackup"; } This gives us a base URL

@RequirePOST @Restricted(NoExternalUse.class) @RestrictedSince("1.4") public void doBackup(StaplerRequest req, StaplerResponse rsp) throws Exception

The doBackup will define a sub-path inside the base URL(/periodicbackup/backup) and be set up for allowing POST operations (needed when we are submitting a form for example). We set this using by specifying '@RequirePOST' and specifying a method with a do.

Here's another example: https://github.com/jenkinsci/cloudbees-jenkins-advisor-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/advisor/AdvisorGlobalConfiguration.java where there's a POST being made at /cloudbees-jenkins-advisor/configure (and we can define an XHR inside a jelly form where we are making a POST request to this URL, the workflow looks like this: the form send a post request to a subpath and there's a corresponding method to handle this request).

GouravSardana commented 2 years ago

Let me see and get back to you if I need any help

mPokornyETM commented 1 year ago

Hi I am not sure it is this so 'good first issue' but I will try to fix some of them. For ex. the lockable-resource really breaks the global config page. So let´s go to fix it.

i-am-yuvi commented 7 months ago

Hey, @ShrutiC-git I think no one is working on this issue. I will be contributing to it.

mPokornyETM commented 7 months ago

all kind of contributions are welcome

i-am-yuvi commented 7 months ago

Here's another reference document that has all the plugins which extend from this class: https://tempora-mutantur.github.io/jenkins.io/github_pages_test/doc/developer/extensions/jenkins-core/#managementlink

So once we start using ManagementLink Class, we will not need to use GlobalConfiguration anymore. Both work a bit differently: anything under global configuration uses a load/save mechanism is implemented using unmarshalling XML, which essentially means that we convert the XML into Java objects, and use it later.

For the ManagementLink, there's no default method of loading/saving, and that's because the save mechanism for anything that is under the Manage section of Jenkins should define the plugin developers want to save information. Some maybe don't necessarily want to save any information and just display status/text.

For example, consider this: https://github.com/jenkinsci/periodicbackup-plugin/blob/master/src/main/java/org/jenkinsci/plugins/periodicbackup/PeriodicBackupLink.java (PeriodicBackupPlugin) which uses a similar XML unmarshalling to save/load. So two things here:

@Override public String getUrlName() { return "periodicbackup"; } This gives us a base URL

@RequirePOST @Restricted(NoExternalUse.class) @RestrictedSince("1.4") public void doBackup(StaplerRequest req, StaplerResponse rsp) throws Exception

The doBackup will define a sub-path inside the base URL(/periodicbackup/backup) and be set up for allowing POST operations (needed when we are submitting a form for example). We set this using by specifying '@RequirePOST' and specifying a method with a do.

Here's another example: https://github.com/jenkinsci/cloudbees-jenkins-advisor-plugin/blob/master/src/main/java/com/cloudbees/jenkins/plugins/advisor/AdvisorGlobalConfiguration.java where there's a POST being made at /cloudbees-jenkins-advisor/configure (and we can define an XHR inside a jelly form where we are making a POST request to this URL, the workflow looks like this: the form send a post request to a subpath and there's a corresponding method to handle this request).

Thanks for sharing this!

This actually saved a lot of time, now I understand that when we extend the managementLink we need to create the load and save mechanism because there is no default load/save method in the management link class.

i-am-yuvi commented 6 months ago

all kind of contributions are welcome

Hey I am facing some issue, can you help me out? @ShrutiC-git

mPokornyETM commented 6 months ago

I think, there is more then one issue ;-) What you need ?

i-am-yuvi commented 6 months ago

No, I just wanted someone to review the code. I mean there is some issue regarding that. If you could help me with that.

mPokornyETM commented 6 months ago

ping me on gitter to eliminate the wste here ;-) https://matrix.to/#/@mpokornyetm-612cc2bd6da0373984845411:gitter.im

i-am-yuvi commented 6 months ago

sure! On Fri, Feb 16, 2024, 23:17 Martin Pokorny @.***> wrote:

ping me on gitter to eliminate the wste here ;-) @.***:gitter.im

— Reply to this email directly, view it on GitHub https://github.com/jenkinsci/cloudevents-plugin/issues/10#issuecomment-1948976541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWFP25HC2FTA33WOKW6AEFLYT6LS5AVCNFSM5FF76NJKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJUHA4TONRVGQYQ . You are receiving this because you commented.Message ID: @.***>