Adding config when plugin updates

26 views
Skip to first unread message

Richard Bywater

unread,
Dec 9, 2017, 10:26:28 PM12/9/17
to jenkin...@googlegroups.com
Hi

I'm making a change to my plugin that will require all instances of a configuration to have a new persistent "id" variable. 

I've dealt with the creation case by having a hidden field and a DataBoundConstructor that sees the id is empty and creates one, but I'd like all instances of the config to have a id variable added in a similar manner when the plugin is updated.

Is this possible or can this id variable only be added when the configuration page is visited and the config re-saved?

Any pointers to docs or previous threads gratefully received - I've hunted around but not been able to use my Google-fu to find anything yet.

Thanks
Richard.

Baptiste Mathus

unread,
Dec 10, 2017, 8:19:05 AM12/10/17
to Jenkins Developers

--
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/CAMui9462bD%2BQ81%2B_9Ye%2BgAaxQVJcBkwfCCb2OS9%2BqdFLG-%3DS2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Richard Bywater

unread,
Dec 10, 2017, 12:56:08 PM12/10/17
to jenkin...@googlegroups.com

Great thanks. That's the page I remember seeing a while back but just couldn't find it again :)

Richard.


On Mon, 11 Dec 2017, 2:19 AM Baptiste Mathus, <m...@batmat.net> wrote:
Hi

I'm making a change to my plugin that will require all instances of a configuration to have a new persistent "id" variable. 

I've dealt with the creation case by having a hidden field and a DataBoundConstructor that sees the id is empty and creates one, but I'd like all instances of the config to have a id variable added in a similar manner when the plugin is updated.

Is this possible or can this id variable only be added when the configuration page is visited and the config re-saved?

Any pointers to docs or previous threads gratefully received - I've hunted around but not been able to use my Google-fu to find anything yet.

Thanks
Richard.

--
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-de...@googlegroups.com.

--
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-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANWgJS5-KSJ_gqeU3w3wR%3DqimH945TLYOTGO5sY9sEBUF3EpNA%40mail.gmail.com.

Richard Bywater

unread,
Dec 12, 2017, 1:11:29 AM12/12/17
to jenkin...@googlegroups.com
I'm one step closer with Baptiste's help but I'm still stuck on persisting the id once I generate it in the readResolve method. This is necessary as its not a default value but instead a random id value that needs to be maintained between Jenkins restarts.

Does anyone have an idea about how this is done? I did try calling 'getDescriptor.save()' but that doesn't seem to help presumably as this is a job level configuration and not the system configuration (although I always get confused between Descriptor/Describables/etc.so that is probably to be expected :) )

Richard.

Stephen Connolly

unread,
Dec 12, 2017, 5:02:13 AM12/12/17
to jenkin...@googlegroups.com
What you might need to do is set a flag that signals at least one readResolve method has assigned an id (or better have a set of newly assigned ids). Then have a @Initializer that fires after Jobs loaded and it checks the flag (or set non-empty) and if set then it iterates all jobs saving ones that have been changed (which is why the set of newly assigned ids is better because: 1. if the config does not have an id in the set then skip; 2. remove entries as you save each job and when the set is empty you can stop without processing all jobs)

On 12 December 2017 at 06:11, Richard Bywater <ric...@byh2o.com> wrote:
I'm one step closer with Baptiste's help but I'm still stuck on persisting the id once I generate it in the readResolve method. This is necessary as its not a default value but instead a random id value that needs to be maintained between Jenkins restarts.

Does anyone have an idea about how this is done? I did try calling 'getDescriptor.save()' but that doesn't seem to help presumably as this is a job level configuration and not the system configuration (although I always get confused between Descriptor/Describables/etc.so that is probably to be expected :) )

Richard.
On Mon, 11 Dec 2017 at 06:55 Richard Bywater <ric...@byh2o.com> wrote:

Great thanks. That's the page I remember seeing a while back but just couldn't find it again :)

Richard.


On Mon, 11 Dec 2017, 2:19 AM Baptiste Mathus, <m...@batmat.net> wrote:
Hi

I'm making a change to my plugin that will require all instances of a configuration to have a new persistent "id" variable. 

I've dealt with the creation case by having a hidden field and a DataBoundConstructor that sees the id is empty and creates one, but I'd like all instances of the config to have a id variable added in a similar manner when the plugin is updated.

Is this possible or can this id variable only be added when the configuration page is visited and the config re-saved?

Any pointers to docs or previous threads gratefully received - I've hunted around but not been able to use my Google-fu to find anything yet.

Thanks
Richard.

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

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

--
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/CAMui947tE8Pp-QL_oidc%3D2g1ep8yGnV9FhtjFGetrYMxZC%3DcMw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages