How can I call a groovy script from a Jenkins file?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to separate out the contents from a Jenkinsfile into a groovy script to make. But it fails to call these scripts: Here is the code: file.groovy Looks like the Jenkinsfile is able to call file1.groovy but always gives me an error: java . lang . NullPointerException : Cannot invoke method firstTest () on null object 回答1: If you want to have methods available in your Jenkinsfile from an external file you need to do the following In your file1.groovy , return references to the methods def firstTest () { // stuff here } def