What is the Jenkins Pipeline `script` block and when should you avoid it?
BeginnerConceptJenkins
Answer
script { } lets you run arbitrary scripted Groovy inside a declarative steps block, for loops, conditionals or variable manipulation that the declarative syntax cannot express. Avoid large script blocks: they bypass declarative validation, are hard to test, and signal the logic should live in a shared library step or an external shell script.
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate