[JIRA] [workflow-plugin] (JENKINS-32508) Workflow does not support the standard Groovy JSON parser: JsonSlurper

25 views
Skip to first unread message

cleclerc@cloudbees.com (JIRA)

unread,
Jan 18, 2016, 3:40:04 PM1/18/16
to jenkinsc...@googlegroups.com
Cyrille Le Clerc created an issue
 
Jenkins / Bug JENKINS-32508
Workflow does not support the standard Groovy JSON parser: JsonSlurper
Issue Type: Bug Bug
Assignee: Jesse Glick
Components: workflow-plugin
Created: 18/Jan/16 8:39 PM
Environment: workflow-aggregator 1.12
jenkins-core 1.625.3.1
Priority: Minor Minor
Reporter: Cyrille Le Clerc

Jenkins Workflow does not support the standard JSON parser of the Groovy Language: JsonSlurper.

This makes it very cumbersome to parse the result of CLI calls such as AWS CLI...

Test case

node {

  println "Parse JSON file as recommended in Groovy Reference Guide http://www.groovy-lang.org/json.html"

  def jsonSlurper = new JsonSlurper()
  def object = jsonSlurper.parseText '''
    { "simple": 123,
      "fraction": 123.66,
      "exponential": 123e12
    }'''

  println object
}

Error Message

Started by user admin
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 5: unable to resolve class JsonSlurper 
 @ line 5, column 19.
   def jsonSlurper = new JsonSlurper()
                     ^

1 error

	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:861)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:550)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:499)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:302)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281)
	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
	at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:106)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:362)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:329)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:208)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:408)
Finished: FAILURE
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

jglick@cloudbees.com (JIRA)

unread,
Jan 18, 2016, 3:43:06 PM1/18/16
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Not A Defect
 

Import the class from the groovy.json package.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Not A Defect
Reply all
Reply to author
Forward
0 new messages