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.

All CI/CD questions

More on Jenkins