简体   繁体   中英

Jenkins Workflow-Plugin and Groovy Libs

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM