简体   繁体   English

重用jenkins管道或groovy脚本?

[英]Reuse jenkins pipeline or groovy script?

We have jenkins pipelines which are reused and some pipelines which use the same functions. 我们有可重复使用的jenkins管道和一些使用相同功能的管道。 Now is my question: what is the right approach to reuse them. 现在是我的问题:什么是重用它们的正确方法。 I use a shared library but I don't know if I have to add groovy scripts or full pipelines? 我使用共享库,但不知道是否必须添加常规脚本或完整管道? The groovy scripts seem to be executed in the root instead of my jenkins workspace which is a big issue. Groovy脚本似乎在根目录而不是在我的jenkins工作区中执行,这是一个大问题。 How are you handling this in the right way? 您如何以正确的方式处理此问题?

Using shared library is the right approach. 使用共享库是正确的方法。 You have to add just groovy scripts to your library and use them in your pipeline. 您只需要在库中添加常规脚本即可在管道中使用它们。

Have a look at an example, Pipeline and the associated library . 看一个示例Pipeline和相关的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM