def props = readJSON text: [ 'buildName':"${params.buildName}", 'targetRepo':"${params.artifactoryReleases}"]
echo props.buildName
echo props.targetRepo
Getting the following error
org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class java.lang.String at org.kohsuke.stapler.ClassDescriptor.loadConstructorParamNames(ClassDescriptor.java:265) at org.jenkinsci.plugins.structs.describable.DescribableModel.(DescribableModel.java:122) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:380)
Caused: java.lang.IllegalArgumentException: Could not instantiate {text={buildName=alu-rp, targetRepo=na-generic-releases}} for ReadJSONStep(file?: String, text?: String) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:264) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)
Since your props
are in JSON, you need to convert it to string in order to echo it
Try: echo props.toString()
You can also use print
instead, conversion to string is not necessary:
print props
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With