Challenge - 5 Problems
Master of Steps within Stages
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of multiple steps in a Jenkins stage
Consider the following Jenkins pipeline stage snippet. What will be the output in the Jenkins console when this stage runs?
Jenkins
stage('Build') { steps { echo 'Step 1: Compile' echo 'Step 2: Test' echo 'Step 3: Package' } }
Attempts:
2 left
💡 Hint
Remember Jenkins runs steps in the order they are written inside the stage.
✗ Incorrect
Jenkins executes steps sequentially inside a stage. Each echo prints its message on a new line in the console output.
❓ Configuration
intermediate2:00remaining
Correct syntax for multiple steps in a Jenkins stage
Which of the following Jenkins pipeline stage configurations correctly defines multiple steps inside a stage?
Attempts:
2 left
💡 Hint
Steps must be inside the 'steps' block using curly braces.
✗ Incorrect
In Jenkins declarative pipeline, multiple steps must be inside a 'steps' block using curly braces. Option A follows this syntax correctly.
❓ Troubleshoot
advanced2:00remaining
Why does this Jenkins stage fail to run all steps?
Given this Jenkins stage, only the first step runs and the others are skipped. What is the cause?
Jenkins
stage('Test') { steps { echo 'Running tests' return echo 'Tests complete' } }
Attempts:
2 left
💡 Hint
Think about what 'return' does inside a block of code.
✗ Incorrect
The 'return' statement immediately exits the current block or function, so any steps after it are not executed.
🔀 Workflow
advanced2:00remaining
Order of step execution in parallel and sequential stages
In this Jenkins pipeline snippet, which step runs last?
Jenkins
stage('Build') { steps { echo 'Compile' } } stage('Test and Package') { parallel { stage('Test') { steps { echo 'Run tests' } } stage('Package') { steps { echo 'Create package' } } } } stage('Deploy') { steps { echo 'Deploy application' } }
Attempts:
2 left
💡 Hint
Parallel stages run at the same time, but the next stage waits for them to finish.
✗ Incorrect
The 'Deploy' stage runs after 'Build' and the parallel 'Test' and 'Package' stages complete. So 'Deploy application' is printed last.
✅ Best Practice
expert2:00remaining
Best practice for grouping multiple shell commands in a Jenkins step
Which option shows the best way to run multiple shell commands as a single step inside a Jenkins stage?
Attempts:
2 left
💡 Hint
Think about readability and how Jenkins executes shell commands.
✗ Incorrect
Using a multiline string (triple quotes) inside a single sh step groups commands clearly and runs them in one shell session, improving readability and performance.