简体   繁体   English

Jenkins 管道和共享库之间的区别

[英]Difference between Jenkins pipeline and Shared library

I wanted to get a clear understanding of the difference between Jenkins pipeline and Shared library concept.我想清楚地了解 Jenkins 管道和共享库概念之间的区别。 If someone using it can you kindly clarify.如果有人使用它,请您澄清一下。 Thanks!谢谢!

I found this documentation for the Shared library.我找到了共享库的这个文档。 Hope this might help https://jenkins.io/doc/book/pipeline/shared-libraries/希望这可能会有所帮助https://jenkins.io/doc/book/pipeline/shared-libraries/

Here is an example for the same: https://tomd.xyz/jenkins-shared-library/这是相同的示例: https : //tomd.xyz/jenkins-shared-library/

A Jenkins Pipeline is usually one of many configurations that Jenkins has. Jenkins 流水线通常是 Jenkins 拥有的众多配置之一。 A Pipeline is a very generic term for logic that is executed on a git repository for example.例如,管道是在 git 存储库上执行的逻辑的非常通用的术语。

On the other hand a shared library is like the name says a library that contains a specific function or logic.另一方面,共享库就像名称所说的包含特定功能或逻辑的库。 This specific function can be imported for multiple Jenkins Pipelines.可以为多个 Jenkins 管道导入此特定功能。 A use case would be to prevent duplicate code.一个用例是防止重复代码。

An example would be you have a function that prints Hello World .一个例子是你有一个打印Hello World的函数。 Instead of writing the function 4 times for 4 Jenkins Pipelines - You create a shared library and import the function in each Pipeline.无需为 4 个 Jenkins 管道编写 4 次函数 - 您创建一个共享库并在每个管道中导入该函数。 Basically just the base concept of libraries for programming languages.基本上只是编程语言库的基本概念。

The official documentation describes it pretty well too: 官方文档也很好地描述了它:

As Pipeline is adopted for more and more projects in an organization, common patterns are likely to emerge.随着组织中越来越多的项目采用流水线,很可能会出现通用模式。 Oftentimes it is useful to share parts of Pipelines between various projects to reduce redundancies and keep code "DRY".通常,在不同项目之间共享部分 Pipelines 以减少冗余并保持代码“DRY”是很有用的。

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

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