jenkinsfile doesn't recognize @Grab [closed]

不问归期 提交于 2019-12-11 02:42:49

问题


I want to use @Grab to include a yaml parsing library inside my Jenkinsfile. I add this line in my Jenkinsfile:

@Grab('org.yaml:snakeyaml:1.17')

https://bitbucket.org/asomov/snakeyaml

However, the Jenkins run can't recognize this and return an error.


回答1:


You cannot use @Grab in pipelines at the moment. I doubt it will be added as a feature because Jenkins CPS needs source code to be able to perform CPS transofmrations, and @Grab uses binary dependencies. You can only use @Grab from trusted shared libraries. From the docmentation:

It is possible to use third-party Java libraries, typically found in Maven Central, from trusted library code using the @Grab annotation. Refer to the Grape documentation for details, but simply put:



来源:https://stackoverflow.com/questions/51328182/jenkinsfile-doesnt-recognize-grab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!