A stage is a major phase in a Jenkins pipeline that groups related steps together. It helps organize the pipeline into clear sections like Build, Test, and Deploy.
Click to reveal answer
beginner
What is a step in a Jenkins pipeline?
A step is a single task or command executed inside a stage. For example, running a shell command or checking out code.
Click to reveal answer
intermediate
How do stages help in visualizing a Jenkins pipeline?
Stages appear as separate blocks in the Jenkins UI, showing progress and results for each phase. This makes it easy to see where the pipeline is and if any stage failed.
Click to reveal answer
beginner
Write a simple Jenkins pipeline snippet with two stages: Build and Test.
The stage block must have curly braces enclosing its content: stage('Deploy') { ... }.
Step 2: Identify missing braces
In the snippet, the stage declaration lacks opening and closing braces around steps.
Final Answer:
Missing curly braces after stage declaration -> Option B
Quick Check:
Stage needs braces { } = D [OK]
Hint: Always use braces {} after stage('name') [OK]
Common Mistakes:
Forgetting braces after stage name
Placing steps outside stages block
Misunderstanding agent syntax
5. You want to create a Jenkins pipeline with two stages: Build and Test. The Test stage should only run if the Build stage succeeds. Which pipeline snippet correctly implements this logic?
The snippet with when { expression { currentBuild.result == 'SUCCESS' } } uses the correct property result instead of currentResult. The snippet with when { branch 'main' } conditions on Git branch. The snippet with post { success { ... } } adds an unrelated post-action block.