0
0
Jenkinsdevops~10 mins

Scripted vs declarative comparison in Jenkins - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - Scripted vs declarative comparison
Start Pipeline
Groovy Code Blocks
Manual Flow Control
Flexible, Complex
Pipeline Runs
Results & Logs
This flow shows how Jenkins pipelines start and split into scripted and declarative styles, highlighting their structure and execution.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps { echo 'Building...' }
    }
  }
}
A simple declarative pipeline that runs a build stage printing a message.
Process Table
StepPipeline TypeActionCode/StructureResult
1ScriptedStart pipelinenode { ... }Pipeline initialized
2ScriptedDefine stages manuallystage('Build') { ... }Stages set up
3ScriptedWrite Groovy code for stepsecho 'Building...'Build step runs
4ScriptedPipeline completesEnd of scriptPipeline finished
5DeclarativeStart pipelinepipeline { ... }Pipeline initialized
6DeclarativeDefine agent and stagesagent any, stages { ... }Stages structured
7DeclarativeDefine steps declarativelysteps { echo 'Building...' }Build step runs
8DeclarativePipeline completesEnd of pipeline blockPipeline finished
9BothCompare resultsN/ABoth run build step, differ in syntax and flexibility
💡 Both pipelines finish after running the build step; scripted uses Groovy code blocks, declarative uses structured syntax.
Status Tracker
VariableStartAfter Scripted Stage SetupAfter Scripted StepAfter Declarative Stage SetupAfter Declarative StepFinal
pipelineStateNot startedInitializedBuild step executedInitializedBuild step executedFinished
syntaxStyleN/AGroovy code blocksGroovy code blocksStructured blocksStructured blocksN/A
Key Moments - 2 Insights
Why does the scripted pipeline look like normal code while declarative looks like a config?
Scripted pipelines use Groovy code blocks allowing manual control (see execution_table rows 1-4), while declarative pipelines use a structured syntax with predefined sections (rows 5-8) for simplicity.
Can both pipelines do the same tasks?
Yes, both run the same build step (rows 3 and 7), but scripted pipelines allow more complex logic, while declarative pipelines focus on readability and standard structure.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the scripted pipeline run the build step?
AStep 3
BStep 2
CStep 7
DStep 5
💡 Hint
Check the 'Action' and 'Pipeline Type' columns for scripted pipeline build step.
At which step does the declarative pipeline define its stages?
AStep 2
BStep 3
CStep 6
DStep 8
💡 Hint
Look for 'Declarative' pipeline type and 'Define agent and stages' action.
If you want more manual control over the pipeline flow, which style would you choose?
ADeclarative
BScripted
CBoth are equal
DNeither
💡 Hint
Refer to variable_tracker 'syntaxStyle' and execution_table scripted pipeline steps.
Concept Snapshot
Scripted Pipeline:
- Uses Groovy code blocks
- Manual flow control
- Flexible, complex logic

Declarative Pipeline:
- Uses structured syntax
- Predefined sections (agent, stages)
- Simpler, readable

Both run pipeline steps but differ in syntax and control style.
Full Transcript
This visual execution compares scripted and declarative Jenkins pipelines. The flow starts with pipeline initialization, then splits into scripted pipelines using Groovy code blocks with manual control, and declarative pipelines using structured syntax with predefined sections. The execution table traces steps where each pipeline defines stages and runs a build step. Variables track pipeline state and syntax style changes. Key moments clarify why scripted looks like code and declarative like config, and confirm both can run the same tasks. The quiz tests understanding of when build steps run and which style offers more control. The snapshot summarizes key differences: scripted is flexible and code-like, declarative is simpler and structured.