当前位置:网站首页>Jenkins pipeline syntax

Jenkins pipeline syntax

2022-06-24 12:24:00 Chen Bucheng I

One . declarative

declarative Pipeline Must be included in a file named pipeline In the statement block of , Typical declarative Pipeline The grammar is as follows

  1. pipeline {
  2. agent any
  3. environment {}
  4. stages {
  5. stage("Build"){
  6. steps {
  7. sh 'echo Building...
  8. }
  9. }
  10. stage("Test"){
  11. steps {
  12. sh 'echo Testing...'
  13. }
  14. }
  15. }
  16. }

A legal Pipeline Follow these principles :

  • The top-level statement block can only be pipeline {}
  • Each statement can only be written on one line , There is no separator , For example, semicolon “;”
  • Building blocks can only be Sections、Directive、steps Or one of the assignment statements
  • All property references are treated as method calls without parameters , for example input Equate to input()

Two . Scripted

Scripted Pipeline The requirements for grammar are relatively loose , The top layer can be node, It can also be stage.node Can be nested stage,stage Conversely, you can nest node. Typical scripted Pipeline The grammar is as follows :

  1. node {
  2. stage("Build"){
  3. sh 'echo Building...'
  4. }
  5. stage("Test"){
  6. sh 'echo Testing...'
  7. }
  8. }
原网站

版权声明
本文为[Chen Bucheng I]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/06/20210602191027495C.html