简体   繁体   English

Jenkins共享库:/ vars文件夹和/ src文件夹中的函数有什么区别?

[英]Jenkins shared library: what is the difference between functions in /vars folder and /src folders?

I have followed jenkins extending pipeline with shared libraries 我跟随jenkins 扩展管道与共享库
it was mentioned that 有人提到过

The src directory should look like standard Java source directory structure. src目录应该看起来像标准的Java源目录结构。 This directory is added to the classpath when executing Pipelines. 执行管道时,此目录将添加到类路径中。

while the vars directory hosts scripts that define global variables accessible from Pipeline 而vars目录托管定义可从Pipeline访问的全局变量的脚本

Note: I am more curious about the difference in usage not in implementation. 注意:我对使用中的差异而不是实现更感到好奇。

Ok, well, you can see some sample differences in usage by simply examining the samples on the Extending with Shared Libraries page that you've probably already seen. 好的,您可以通过简单地检查您可能已经看到的“ 使用共享库扩展”页面上的示例来查看使用中的一些示例差异。 For instance, if you look for the "Zot.groovy" example, you'll see that the code that uses this has to "new" the "Zot" class. 例如,如果您查找“Zot.groovy”示例,您将看到使用它的代码必须“新”“Zot”类。 However, if you look at the "vars/acme.groovy" sample, you'll see that the user code doesn't have to "new" anything, because the global variable named "acme" exists to be referenced by the script. 但是,如果查看“vars / acme.groovy”示例,您将看到用户代码不需要“新”任何内容,因为脚本会引用名为“acme”的全局变量。

There are other differences, but that's one simple contrast. 还有其他差异,但这是一个简单的对比。

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

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