Introduction
Sometimes you need more control and flexibility in your Jenkins pipelines than the simple, easy-to-read style offers. Scripted pipelines let you write code that can do complex tasks and decisions step-by-step, solving problems that the simpler style can't handle well.
When your build process needs complex loops or conditional logic that declarative syntax cannot express easily.
When you want to write custom Groovy code to interact with Jenkins internals or plugins.
When you need to dynamically create or modify pipeline steps based on runtime information.
When you want full control over the flow of your pipeline without the restrictions of declarative rules.
When migrating older Jenkins pipelines that were originally written in scripted style.