2017-03-02 76 views
0

我正在为詹金斯管道编写一些ci脚本。经常发生的模式是如何在本地测试我的jenkins ci管道?

dir("path/to/stuff"){ 
    do_stuff() 
} 

我想'测试运行'这些脚本来实现(非常)短的反馈循环。但我立即发现这种方法不是'官方'的常规方法。

$ groovy ci/test-ci-scripts.groovy 
Caught: groovy.lang.MissingMethodException: No signature of method: 
    test-ci-scripts.dir() is applicable for argument types: .... 

我需要导入什么才能使其运行?

回答

1

只使用单引号的

dir('path') { 
    // some block 
} 

工作正常,我。 (你可以在Jenkins管道代码生成器中找到dir

+0

并且你可以在命令行运行'groovy my-ci-script.groovy'吗? – xtofl

+0

我真的不确定,如果这能起作用,至少如果a)退出Jenkins DSL或b)调用Jenkins Java API。 – StephenKing