pipeline 脚本是有groovy语言实现的,无需专门学习 groovy pipeline支持两种语法: - Declarative 声明式
- Scripted pipeline脚本式
如何创建基本的pipeline - 直接在jenkins web ui网页界面输入脚本
- 通过常见一个jenkins可以检入项目的源代码管理库
Declarative 声明式pipeline 声明式pipeline基本语法和表达式遵循groovy语法,但是有以下例外: - 声明式pipeline必须包含在固定格式的pipeline{}块内
- 每个声明语句必须独立一行,行尾无需使用分号
- 块(Blocks{})只能包含章节(Sections),指令(Directives),步骤(Steps),或者赋值语句
- 属性引用语句被视为无参数方法调用,如input()
- 块(Blocks{}):由大括号括起来的语句: 如Pipeline{}, Sections{}, parameters{}, script{}
- 章节(Sections):通常包括一个或者多个指令或步骤,如agent,post,stages,steps
- 指令(Directives): environment, options, parameters, triggers, stage, tools, when
- 步骤(steps):执行脚本式pipeline, 如script{}
|