简体   繁体   中英

Unable to compile groovy script in Jenkins

The script is working fine in groovy console. But when I do check-syntax for the same script in Jenkins, the following error message is coming up -

Script1.groovy: 6: unable to resolve class groovyx.net.http.RESTClient
@ line 6, column 1.
import groovyx.net.http.RESTClient
^
Script1.groovy: 4: unable to resolve class groovyx.net.http.ContentType
@ line 4, column 1.
import groovyx.net.http.ContentType
^
Script1.groovy: 3: unable to resolve class groovyx.net.http.HTTPBuilder
@ line 3, column 1.
import groovyx.net.http.HTTPBuilder....

How to get this issue resolved?

This exception is because you dont have these dependencies (Jars) that has these classes so you have two option : 1- if you currently using any dependency management framework like (maven,gradle) then just add these dependencies 2- in the groovy file at the top add @Grapes and then add the dependency here an example :

    @Grapes(
        @Grab(group='yourDependencyGroupID', module='yourDependencyArtifactID'
                                           , version='theDesireVersion')
    )

you can search for these dependencies in Maven Repository

i hope this will help :)

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