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 <[email protected]> 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 <[email protected]> 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, <[email protected]> wrote: >> >>> https://wiki.jenkins.io/display/JENKINS/Hint+on+retaining+backward+ >>> compatibility#Hintonretainingbackwardcompatibility-Scenario: >>> Addinganewfield ? >>> >>> 2017-12-10 4:26 GMT+01:00 Richard Bywater <[email protected]>: >>> >>>> 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 [email protected]. >>>> 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 >>>> <https://groups.google.com/d/msgid/jenkinsci-dev/CAMui9462bD%2BQ81%2B_9Ye%2BgAaxQVJcBkwfCCb2OS9%2BqdFLG-%3DS2g%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> 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 [email protected]. >>> To view this discussion on the web visit https://groups.google.com/d/ >>> msgid/jenkinsci-dev/CANWgJS5-KSJ_gqeU3w3wR% >>> 3DqimH945TLYOTGO5sY9sEBUF3EpNA%40mail.gmail.com >>> <https://groups.google.com/d/msgid/jenkinsci-dev/CANWgJS5-KSJ_gqeU3w3wR%3DqimH945TLYOTGO5sY9sEBUF3EpNA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > 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 [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/jenkinsci-dev/CAMui947tE8Pp-QL_oidc%3D2g1ep8yGnV9FhtjFGetrYMxZC% > 3DcMw%40mail.gmail.com > <https://groups.google.com/d/msgid/jenkinsci-dev/CAMui947tE8Pp-QL_oidc%3D2g1ep8yGnV9FhtjFGetrYMxZC%3DcMw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CA%2BnPnMxBqO9q-e47VpCfmn1Ui9sgsqE3uMJsgfJkpKBQKdYvfA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
