Jenkins: Scripted vs Declarative Pipelines

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

and

https://jenkins.io/doc/book/pipeline/syntax/#scripted-pipeline

 

Scripted is a general purpose DSL and executed from the top of a Jenkinsfile downwards like most traditional scripts in Groovy.

E.g. of if/else and try/catch/throwhttps://jenkins.io/doc/book/pipeline/syntax/#flow-control

 

Notes:

  • Declarative pipelines have a pipeline block. e.g.

  • executing a scripted pipeline in a Declarative Pipeline

a script step takes a block of Scripted Pipeline and executes that in the Declarative Pipeline

Jenkins: node, stage, step

node

node allocates an executor on a Jenkins node (aka a slave) and runs code in the context of the workspace on that node.

https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#node-allocate-node

Another wrinkle on node‘s. There is also the concept of flyweight and heavyweight executors. A flyweight executor is just a thread and runs inside the Java master’s JVM. A heavyweight executor is a process (e.g. sh ) and will halt the flow on the master so should be allocated to a node. From the docs:

It is recommended to allocate executors to agent machines, rather than on the Jenkins master – to avoid potential security vulnerabilities, Out-Of-Memory and other performance issues. To do this, configure the “# of executors” to ‘0’ on the “master” node (by default this setting is ‘2’).

https://support.cloudbees.com/hc/en-us/articles/216456477-What-is-a-Jenkins-Executor-and-how-can-I-best-utilize-my-executors

See also https://support.cloudbees.com/hc/en-us/articles/360012808951-Pipeline-Difference-between-flyweight-and-heavyweight-Executors

stage

stage creates a labelled block and show up as columns in the Pipeline Stage view.

https://jenkins.io/doc/pipeline/steps/pipeline-stage-step/

See also Jenkins: milestone plugin and this post on Stage vs Lock vs Milestone.

step

A step is a single action. When a step succeeds it moves onto the next step. When a step fails to execute correctly the Pipeline will fail.

https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#step-general-build-step

See also

https://stackoverflow.com/questions/39549215/what-is-the-difference-between-a-node-stage-and-step-in-jenkins-pipelines

 

Note also the keyword steps

https://jenkins.io/doc/pipeline/tour/running-multiple-steps/