简体   繁体   English

无法在詹金斯编译groovy脚本

[英]Unable to compile groovy script in Jenkins

The script is working fine in groovy console. 该脚本在groovy控制台中运行良好。 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 : 此异常是因为您没有具有这些类的这些依赖项(Jars),所以有两个选择:1-如果您当前正在使用任何依赖项管理框架(如(maven,gradle)),则只需添加这些依赖项2-在groovy文件中顶部添加@Grapes,然后在此处添加依赖项的示例:

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

you can search for these dependencies in Maven Repository 您可以在Maven存储库中搜索这些依赖项

i hope this will help :) 我希望这个能帮上忙 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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