问题
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