Newbie question: pipeline {} vs node {}

24 views
Skip to first unread message

Christoph Ruepprich

unread,
Oct 31, 2017, 10:37:24 AM10/31/17
to Jenkins Users
Looking at some pipeline scripting examples, I see that there are two different ways to script a pipeline. One begins with pipeline {} the other with node {}. What is the difference between the two, and when would I use one or the other?

thanks,
C

Robert Hales

unread,
Oct 31, 2017, 10:53:58 AM10/31/17
to Jenkins Users
There are 2 different syntaxes. Declarative is the pipeline{} style. scripted doesn't necessarily start with node{}, but uses that heavily. 

Scripted syntax is basically a straight groovy code DSL. Use it when you need to do more complex and interesting things and aren't afraid to get down into writing code. 

Declarative syntax is a more friendly and easy-to-learn syntax. It can be intermingled with scripted in many ways, so I usually like to start with a declarative pipeline and as things start to get more complex where I have had to use too many script{} block or other straight groovy, then I'll consider scraping the declarative framework and converting to a straight groovy script. 

Christoph Ruepprich

unread,
Oct 31, 2017, 11:09:17 AM10/31/17
to Jenkins Users
Thanks Robert,
it helps a lot just knowing what the two different systems are called (declarative vs. scripted).

Cheers,
C
Reply all
Reply to author
Forward
0 new messages