How to persist Global config Data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to persist Global config Data

phanikumar
I have created a Global config variable to store some value and retrieve it
during the execution. Now, I was able to access the data from the Global
variable that I have declared. But to my surprise, I am unable to view the
data when I go to configuration for next time. But still, I am able to
access the field value. Thanks in Advance.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"
xmlns:d="jelly:define" xmlns:l="/lib/layout"
    xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:a="/lib/auth">
         <f:section title="${%Google Cloud}">
                <f:entry title="${%Gcloud Installer Path}" field="gcloudpath">
            <f:textbox name="gcloudpath"/>
          </f:entry>
        </f:section>
</j:jelly>



@Override
        public boolean configure(StaplerRequest req, JSONObject formData)
throws FormException {
            // To persist global configuration information,
            // set that to properties and call save().
            gcloudpath = formData.getString("gcloudpath");
            // ^Can also use req.bindJSON(this, formData);
            //  (easier when there are many fields; need set* methods for
this, like setUseFrench)
            save();
            return super.configure(req,formData);
        }

Following are the sample code snippets. Please don't mind if I did a silly
mistake.



--
Sent from: http://jenkins-ci.361315.n4.nabble.com/Jenkins-dev-f387835.html

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1509042613403-0.post%40n4.nabble.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to persist Global config Data

Daniel Beck

> On 26. Oct 2017, at 20:30, phanikumar <[hidden email]> wrote:
>
> I am unable to view the
> data when I go to configuration for next time. But still, I am able to
> access the field value.

do you have a method `public String getGcloudpath()`? (Note capitalization, needs to match the field name except get + uppercased first letter.)

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/A670CAF1-849F-4CD6-884C-807552EFB6B3%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to persist Global config Data

phanikumar
I found the culprit it's the capital. I have created the method.

public String getGcloudPath(){}

Instead of public String getGcloudpath(){}

Thanks for the reply.



--
Sent from: http://jenkins-ci.361315.n4.nabble.com/Jenkins-dev-f387835.html

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1509046532031-0.post%40n4.nabble.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to persist Global config Data

Jesse Glick-4
In reply to this post by phanikumar
On Thu, Oct 26, 2017 at 2:30 PM, phanikumar
<[hidden email]> wrote:
> I have created a Global config variable to store some value and retrieve it
> during the execution.

https://github.com/jenkinsci/archetypes

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr14z%3D%3DmQA_zGUhjT8%3D-7gGUvcYogJK8iDP0ELbqU3yr2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.