我想使用 @Grab 在我的 Jenkinsfile 中包含一个 yaml 解析库。我在 Jenkinsfile 中添加了这一行:
@Grab('org.yaml:snakeyaml:1.17')
https://bitbucket.org/asomov/snakeyaml
但是,Jenkins 运行无法识别这一点并返回错误。
最佳答案
目前您无法在管道中使用@Grab
。我怀疑它是否会作为一项功能添加,因为 Jenkins CPS 需要源代码才能执行 CPS 转换,而 @Grab
使用二进制依赖项。您只能使用受信任共享库中的@Grab
。来自 the documentation :
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:
关于jenkinsfile 无法识别@Grab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51328182/