0
0
Jenkinsdevops~10 mins

Build steps execution in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Build steps execution
Start Build Job
Execute Step 1
Step 1 Success?
NoFail Build
Yes
Execute Step 2
Step 2 Success?
NoFail Build
Yes
...
All Steps Success
Build Success
End
The build job starts and runs each step in order. If any step fails, the build stops and fails. If all steps succeed, the build finishes successfully.
Execution Sample
Jenkins
stage('Build') {
  steps {
    echo 'Compiling code'
    sh 'make compile'
  }
}
stage('Test') {
  steps {
    echo 'Running tests'
    sh 'make test'
  }
}
This Jenkins pipeline runs a build stage to compile code, then a test stage to run tests.
Process Table
StepActionCommand/MessageResultNext Step
1Start Build JobN/ABuild job startedExecute Step 1
2Execute Step 1echo 'Compiling code'Message printedExecute Step 1 command
3Execute Step 1 commandsh 'make compile'Compile successExecute Step 2
4Execute Step 2echo 'Running tests'Message printedExecute Step 2 command
5Execute Step 2 commandsh 'make test'Tests passedBuild Success
6Build SuccessN/ABuild finished successfullyEnd
7EndN/ABuild job endedN/A
💡 Build ends after all steps succeed or if any step fails (not shown here as all succeed).
Status Tracker
VariableStartAfter Step 1After Step 2Final
Build StatusNot startedRunningRunningSuccess
Step ResultN/ASuccessSuccessN/A
Key Moments - 2 Insights
What happens if the 'make compile' command fails?
If 'make compile' fails (see execution_table row 3), the build stops immediately and is marked as failed. Subsequent steps do not run.
Why do we see 'Message printed' before running shell commands?
The echo commands print messages to the console to inform what is happening. This helps track progress before running actual commands (rows 2 and 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the build status after Step 1 command completes?
AFailed
BSuccess
CRunning
DNot started
💡 Hint
Check variable_tracker column 'After Step 1' for 'Build Status'.
At which step does the build finish successfully?
AStep 4
BStep 6
CStep 5
DStep 7
💡 Hint
Look at execution_table row where 'Build Success' is noted.
If the 'make test' command fails, what happens next?
ABuild is marked as failed and stops
BBuild continues to next step
CBuild restarts from Step 1
DBuild ignores failure and finishes successfully
💡 Hint
Refer to concept_flow where failure at any step leads to 'Fail Build'.
Concept Snapshot
Jenkins build steps run in order.
Each step runs commands or scripts.
If a step fails, build stops and fails.
Success means all steps completed.
Echo commands show progress messages.
Shell commands run actual build/test tasks.
Full Transcript
In Jenkins, a build job runs multiple steps one after another. Each step can print messages or run commands like compiling code or running tests. The job starts and executes the first step. If it succeeds, it moves to the next step. If any step fails, the build stops immediately and is marked as failed. If all steps succeed, the build finishes successfully. Echo commands help show progress messages in the console. Shell commands perform the actual work. Tracking the build status and step results helps understand the job's progress and outcome.