Jenkins脚本化管道或声明性管道 [英] Jenkins scripted pipeline or declarative pipeline

查看:128
本文介绍了Jenkins脚本化管道或声明性管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将旧样式的基于项目的工作流程转换为基于Jenkins的管道.在浏览 docs 时,我发现有两种名为scripteddeclarative的不同语法.例如最近(2016年底)发布的Jenkins Web declarative语法.尽管有一个新的语法版本,Jenkins仍然也支持脚本语法.

I'm trying to convert my old style project base workflow to a pipeline based on Jenkins. While going through docs I found there are two different syntaxes named scripted and declarative. Such as the Jenkins web declarative syntax release recently (end of 2016). Although there is a new syntax release Jenkins still supports scripted syntax as well.

现在,我不确定这两种类型在哪种情况下是最佳匹配. scripted语法将很快被弃用吗?那么declarative将成为詹金斯管道的未来吗?

Now, I'm not sure in which situation each of these two types would be a best match. scripted syntax will be deprecated soon? So will declarative be the future of the Jenkins pipeline?

任何可以分享有关这两种语法类型的想法的人.

Anyone who can share some thoughts about these two syntax types.

推荐答案

首次创建Jenkins Pipeline时,选择Groovy作为基础. Jenkins长期以来一直提供嵌入式Groovy引擎,以为管理员和用户提供高级脚本功能.此外,Jenkins Pipeline的实现者发现Groovy是构建现在称为脚本管道" DSL的坚实基础.

When Jenkins Pipeline was first created, Groovy was selected as the foundation. Jenkins has long shipped with an embedded Groovy engine to provide advanced scripting capabilities for admins and users alike. Additionally, the implementors of Jenkins Pipeline found Groovy to be a solid foundation upon which to build what is now referred to as the "Scripted Pipeline" DSL.

由于它是功能齐全的编程环境,因此脚本化管道为Jenkins用户提供了极大的灵活性和可扩展性. Groovy学习曲线通常不是给定团队的所有成员所希望的,因此创建了声明式管道,以提供一种更简单,更自以为是的语法来编写Jenkins Pipeline.

As it is a fully featured programming environment, Scripted Pipeline offers a tremendous amount of flexibility and extensibility to Jenkins users. The Groovy learning-curve isn’t typically desirable for all members of a given team, so Declarative Pipeline was created to offer a simpler and more opinionated syntax for authoring Jenkins Pipeline.

两者基本上都在下面是相同的Pipeline子系统.它们都是管道作为代码"的持久实现.他们都可以使用内置在Pipeline中或由插件提供的步骤.两者都可以利用共享库

The two are both fundamentally the same Pipeline sub-system underneath. They are both durable implementations of "Pipeline as code." They are both able to use steps built into Pipeline or provided by plugins. Both are able to utilize Shared Libraries

然而,它们的区别在于语法和灵活性.声明性限制使用更严格和预定义的结构为用户提供的功能,使其成为更简单的连续交付管道的理想选择.脚本化脚本提供的限制很少,以至于对结构和语法的唯一限制往往是由Groovy本身定义的,而不是由任何特定于管道的系统定义的,因此,它成为高级用户和要求更复杂的用户的理想选择.顾名思义,声明性流水线鼓励使用声明性编程模型.而脚本化管道遵循一种更必要的编程模型.

Where they differ however is in syntax and flexibility. Declarative limits what is available to the user with a more strict and pre-defined structure, making it an ideal choice for simpler continuous delivery pipelines. Scripted provides very few limits, insofar that the only limits on structure and syntax tend to be defined by Groovy itself, rather than any Pipeline-specific systems, making it an ideal choice for power-users and those with more complex requirements. As the name implies, Declarative Pipeline encourages a declarative programming model. Whereas Scripted Pipelines follow a more imperative programming model.

复制自 https://jenkins.io/doc/book/book/pipeline/syntax /#compare

这篇关于Jenkins脚本化管道或声明性管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆