简体   繁体   English

jenkins中freestyle项目和pipeline的区别

[英]difference between freestyle project and pipeline in jenkins

I'm a little confused about Freestyle project and pipeline in jenkins when trying to create new items.尝试创建新项目时,我对 jenkins 中的 Freestyle 项目和管道有些困惑。

When should I create item with Freestyle project?我什么时候应该使用 Freestyle 项目创建项目? And in which case should I use pipeline?在什么情况下我应该使用管道?

Do I need to store config.xml into code repository for future import?我是否需要将 config.xml 存储到代码存储库中以供将来导入? Or any other usage?或者还有其他用法吗?

Thanks for your help.谢谢你的帮助。

if you've used jenkins in the past without using a Jenkinsfile, you've used something more similar to a freestyle project. 如果您在过去使用jenkins而不使用Jenkins文件,那么您使用的东西更类似于自由式项目。

if you hate typing things into CI systems and therefore want to use pipelines as code--where you put all of your CI configuration into a file in source control (Jenkinsfile) and let Jenkins read that file to figure out what to do--use pipelines . 如果你讨厌在CI系统中输入东西,因此想要使用管道作为代码 - 你将所有CI配置放入源代码控制(Jenkinsfile)中的文件中,让Jenkins读取该文件以确定要做什么 - 使用管道 once you know pipelines, there won't be many cases where you'll prefer freestyle projects. 一旦你了解了管道,就不会有很多你喜欢自由式项目的情况。

The difference is that in Pipeline we have the ability to break our jobs out into different stages and we can have whatever stages we'd like to represent the process we use to deploy software and of course, if anything goes wrong, we can see which stage had the problem; 不同之处在于,在Pipeline中,我们有能力将我们的工作分解到不同的阶段,我们可以拥有我们想要代表我们用于部署软件的过程的任何阶段,当然,如果出现任何问题,我们可以看到哪个阶段有问题; for example. 例如。 We even have the ability to add in verification before we proceed. 我们甚至可以在继续之前添加验证。 We have the ability to run stages in parallel so we could have multiple tests executing in separate branches very easily. 我们能够并行运行各个阶段,因此我们可以非常轻松地在不同的分支中执行多个测试。

The main difference I see between Jenkins Freestyle projects and Pipeline is the usage of GUI vs scripting.我看到 Jenkins Freestyle 项目和 Pipeline 之间的主要区别是 GUI 与脚本的使用。

Below are some differences in more detail下面是一些更详细的区别

Freestyle Projects自由式项目

  • Use GUI to add different stages and steps使用 GUI 添加不同的阶段和步骤
  • More suitable for less complex scenarios更适合不太复杂的场景
  • Good for people who are starting to use Jenkins/ CI solutions适合开始使用 Jenkins/CI 解决方案的人
  • Can become hard to achieve what you want when your scenario become more complex当您的场景变得更加复杂时,可能很难实现您想要的

Pipeline Jobs管道作业

  • Use code (Groovy language - this is a Java like language) for giving instructions使用代码(Groovy 语言——这是一种类似 Java 的语言)给出指令
  • Since, everything in one script you can keep that in the source control and have ability to revert back to an earlier version at any time or keep track of changes made to the script因为,一个脚本中的所有内容都可以保留在源代码管理中,并且能够随时恢复到早期版本或跟踪对脚本所做的更改
  • Entire, pipeline consists of steps (ex: build, test, deploy etc..)整个管道由步骤组成(例如:构建、测试、部署等)
  • Created using a Jenkinsfile使用 Jenkinsfile 创建

Jenkinsfile can be one of two of below types Jenkinsfile 可以是以下两种类型之一

  1. Declarative Pipeline (Requires blue ocean plugin to use graphical pipeline editor)声明式管道(需要蓝海插件才能使用图形管道编辑器)
  2. Scripted Pipeline脚本化管道

Usage of config.xml config.xml 的用法

You can append config.xml to the end of the jenkins url(in browser) and view all information related to that job as a xml file.您可以 append config.xml 到 jenkins url 的末尾(在浏览器中)并查看与该作业相关的所有信息作为 xml 文件。 This is also possible for user who do not have write access to that job.这对于没有该作业写入权限的用户也是可能的。 Not sure why do you need to store it in the source code.不确定为什么需要将其存储在源代码中。

Freestyle or Pipeline?自由式还是流水线?

In my opinion, go for the pipeline if you have some experience with Jenkins. But if you're using it for the first time or do not have much experience, starting from Freestyle projects is a good idea and eventually you can convert it into a pipeline and achieve much more complex stuff.在我看来,如果您对 Jenkins 有一些经验,则 go 用于管道。但如果您是第一次使用它或没有太多经验,从 Freestyle 项目开始是个好主意,最终您可以将其转换为管道并实现更复杂的东西。

Hope this helps:)希望这可以帮助:)

如果要为CI CD管道实现UCD工具,请尝试添加改造插件

We can say the main difference between freestyle project and Pipeline. 我们可以说自由式项目和Pipeline之间的主要区别。 with Pipeline, you can write jenkins file using ruby program with this you can configure CI/CD. 使用Pipeline,您可以使用ruby程序编写jenkins文件,您可以配置CI / CD。

If you're a developer, writing your pipeline-as-code will feel more comfortable and natural. 如果您是开发人员,那么编写管道代码将感觉更舒适自然。 If you're a DevOps professional, maintaining your pipeline will be easier because you can treat it like any other set of code that drives key processes. 如果您是DevOps专业人员,维护您的管道将更容易,因为您可以将其视为驱动关键流程的任何其他代码集。

Another aspect you can take into consideration is the fact that you write code in a file.您可以考虑的另一个方面是您在文件中编写代码这一事实。 Therefore you can store it in a git server to keep your old jobs accessible因此,您可以将其存储在 git 服务器中,以保持您的旧作业可访问

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

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