Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Workflow-Plugin and Groovy Libs

Tags:

jenkins

groovy

So, i've just setup a docker container of the current public Jenkinsci image. Installed the Workflow Plugins through the Workflow Aggregator and tried to execute a quite simple script:

node {
    def jsonParser = new JsonSlurper()
    println "done"
}

and on execution i immediately get

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 2: unable to resolve class JsonSlurper 

As the workflow plugins seem to use their own (predefined) groovy libs and not one that is imported through the "normal" groovy plugin in jenkins, is there any way to use things like JsonSlurper from a Workflow script?

Thanks, Indy

like image 533
Rene Avatar asked Sep 06 '25 12:09

Rene


1 Answers

Well, quite embarrassing; of course it had to be something simple that i find out right after posting the question. For future reference: You need to import the class as you would do in plain java:

import groovy.json.JsonSlurper

this has solved the issue.

like image 56
Rene Avatar answered Sep 09 '25 21:09

Rene