Issue
I have installed Pipeline Utility Steps plugin in my Jenkins and I used to use readJSON and readYaml without any issue.
A month later when I tried it i am getting the following error for both of them
groovy.lang.MissingMethodException: No signature of method: Script1.readJSON() is applicable for argument types: (java.util.LinkedHashMap) values: [[file:/data/ecsnames/dev_ECSNames.json]]
The error is similar for readYaml step as well.
I am not sure how it suddenly stopped working. Only thing I got from one of my teammates is that Jenkins was Updated to 2.235.5 version couple of weeks ago.
I used the following command
def clstrndsrvcnme = readJSON file: "/data/ecsnames/dev_ECSNames.json"
can anyone help me with this? And what does this error means?
Update*
So I was trying the above command at JenkinsURL/script. There is a little IDE to run groovy scripts. I do all kinds of Debug there. At that location it was throwing the error.
But when I am running the same commands from a Jenkins Job, it is working perfectly fine and i am able to read values from Yaml and Json. So what I believe is that somehow JenkinsURL/script is not able to use Pipeline Utility Scripts plugin.
I am able to do my work but still wanted to understand why it is failing here JenkinsURL/script.
Solution
I spent most of a day on this same problem. This fails in the Script Console:
def jstring = '{"one":1, "two":2}'
def jobj = readJSON text: jstring
Thanks to your post, I tried it in a test pipe and it works:
pipeline {
agent any
stages {
stage('readjson') {
steps {
script {
def jstring = '{"one":1, "two":2}'
def jobj = readJSON text: jstring
echo jobj.toString()
}
}
}
}
}
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\readJSON
[Pipeline] {
[Pipeline] stage
[Pipeline] { (readjson)
[Pipeline] script
[Pipeline] {
[Pipeline] readJSON
[Pipeline] echo
{"one":1,"two":2}
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
I've logged an issue in the Jenkins Jira for this plugin: https://issues.jenkins.io/browse/JENKINS-65910
I'll update this post with any responses from Jenkins.
Answered By - Max Cascone