How to persist Global config Data

25 views
Skip to first unread message

phanikumar

unread,
Oct 26, 2017, 2:30:20 PM10/26/17
to jenkin...@googlegroups.com
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

Daniel Beck

unread,
Oct 26, 2017, 2:51:06 PM10/26/17
to jenkin...@googlegroups.com

> On 26. Oct 2017, at 20:30, phanikumar <phanikumar...@gmail.com> 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.)

phanikumar

unread,
Oct 26, 2017, 3:35:40 PM10/26/17
to jenkin...@googlegroups.com
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.

Jesse Glick

unread,
Oct 26, 2017, 3:45:28 PM10/26/17
to Jenkins Dev
On Thu, Oct 26, 2017 at 2:30 PM, phanikumar
<phanikumar...@gmail.com> wrote:
> I have created a Global config variable to store some value and retrieve it
> during the execution.

https://github.com/jenkinsci/archetypes
Reply all
Reply to author
Forward
0 new messages