Bird
Raised Fist0
Jenkinsdevops~20 mins

Milestone step for concurrency in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Milestone Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of the Milestone Step in Jenkins Pipelines

What is the main purpose of using the milestone step in a Jenkins pipeline?

ATo pause the pipeline execution until a manual approval is given.
BTo mark a point in the pipeline that prevents older builds from running past it if a newer build has reached the same milestone.
CTo trigger parallel execution of multiple stages simultaneously.
DTo archive build artifacts at a specific stage.
Attempts:
2 left
💡 Hint

Think about how Jenkins manages concurrent builds and avoids outdated work continuing.

💻 Command Output
intermediate
2:00remaining
Output of Pipeline with Milestone Step

Given the following Jenkins pipeline snippet, what will be the output if build #2 reaches the milestone before build #1?

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        milestone 1
        echo "Build stage running"
      }
    }
    stage('Test') {
      steps {
        milestone 2
        echo "Test stage running"
      }
    }
  }
}
ABuild #2 will stop at milestone 1 and not run 'Build stage running'.
BBoth builds run all stages fully without interruption.
CBuild #1 and Build #2 will both stop at milestone 1.
DBuild #1 will stop at milestone 2 and not run 'Test stage running', while Build #2 runs both stages fully.
Attempts:
2 left
💡 Hint

Remember that milestone stops older builds from passing milestones reached by newer builds.

🔀 Workflow
advanced
2:30remaining
Using Milestone to Control Parallel Branches

In a Jenkins pipeline with parallel branches, how can the milestone step be used to ensure that only the latest build's parallel branches proceed beyond a certain point?

AUse <code>milestone</code> inside a single sequential stage, not in parallel branches.
BUse <code>milestone</code> only after all parallel branches complete to stop older builds.
CPlace a <code>milestone</code> step at the start of each parallel branch to stop older builds from continuing in any branch once a newer build passes the milestone.
DMilestone steps cannot be used with parallel branches.
Attempts:
2 left
💡 Hint

Think about how to stop outdated work in each parallel path individually.

❓ Troubleshoot
advanced
2:30remaining
Troubleshooting Unexpected Pipeline Stops with Milestone

A Jenkins pipeline with milestones unexpectedly stops an older build early. What is the most likely cause?

AA newer build has already passed the same milestone, causing the older build to be aborted at that point.
BThe pipeline script has a syntax error causing premature termination.
CThe Jenkins agent lost connection during the build.
DThe milestone step was placed after all stages, so it never triggered.
Attempts:
2 left
💡 Hint

Consider how milestones affect concurrency and build ordering.

✅ Best Practice
expert
3:00remaining
Best Practice for Using Milestone Steps in Complex Pipelines

What is the best practice when placing milestone steps in a complex Jenkins pipeline to manage concurrency effectively?

APlace milestone steps at key points before resource-intensive or long-running stages to prevent older builds from wasting resources.
BAvoid using milestone steps in complex pipelines as they cause unpredictable behavior.
CPlace milestone steps only at the very end of the pipeline to ensure all builds complete fully.
DUse milestone steps only in freestyle jobs, not in pipelines.
Attempts:
2 left
💡 Hint

Think about saving time and resources by stopping outdated builds early.

Practice

(1/5)
1. What is the main purpose of the milestone step in a Jenkins pipeline?
easy
A. To allow only the latest pipeline run to continue past a certain point
B. To trigger a new pipeline run automatically
C. To send notifications when a build fails
D. To archive build artifacts for later use

Solution

  1. Step 1: Understand the role of the milestone step

    The milestone step is designed to control concurrency by ensuring only the newest pipeline run proceeds beyond the milestone point.
  2. Step 2: Compare with other pipeline steps

    Other steps like triggering builds or sending notifications do not control concurrency like milestone does.
  3. Final Answer:

    To allow only the latest pipeline run to continue past a certain point -> Option A
  4. Quick Check:

    Milestone controls concurrency = B [OK]
Hint: Milestone lets only the newest run pass a checkpoint [OK]
Common Mistakes:
  • Confusing milestone with notification steps
  • Thinking milestone triggers builds
  • Assuming milestone archives artifacts
2. Which of the following is the correct syntax to add a milestone step with label "BuildCheckpoint" in a Jenkins declarative pipeline?
easy
A. milestone label: 'BuildCheckpoint'
B. milestone('BuildCheckpoint')
C. milestone label = 'BuildCheckpoint'
D. milestone: 'BuildCheckpoint'

Solution

  1. Step 1: Recall the correct milestone syntax

    The milestone step uses named parameters with the syntax: milestone label: 'LabelName'.
  2. Step 2: Identify syntax errors in other options

    Options B, C, and D have incorrect syntax such as missing named parameter format or wrong punctuation.
  3. Final Answer:

    milestone label: 'BuildCheckpoint' -> Option A
  4. Quick Check:

    Correct milestone syntax uses label: 'name' [OK]
Hint: Use named parameter syntax: milestone label: 'Name' [OK]
Common Mistakes:
  • Using parentheses instead of named parameters
  • Using equal sign instead of colon
  • Omitting the label keyword
3. Given this Jenkins pipeline snippet:
stage('Test') {
  steps {
    milestone label: 'TestStart'
    echo 'Running tests'
  }
}

// Two pipeline runs start quickly one after another
What happens to the first pipeline run when the second run reaches the same milestone?
medium
A. The first run continues normally alongside the second
B. The second run waits until the first run finishes
C. The first run is aborted and only the second run continues past the milestone
D. Both runs are aborted at the milestone

Solution

  1. Step 1: Understand milestone concurrency behavior

    When multiple runs reach the same milestone label, Jenkins allows only the latest run to proceed and aborts older runs at that point.
  2. Step 2: Apply this to the scenario

    The second run reaching 'TestStart' milestone causes the first run to abort at that milestone, so only the second run continues.
  3. Final Answer:

    The first run is aborted and only the second run continues past the milestone -> Option C
  4. Quick Check:

    Milestone aborts older runs = D [OK]
Hint: Milestone aborts older runs, keeps newest only [OK]
Common Mistakes:
  • Thinking both runs continue
  • Assuming second run waits
  • Believing both runs abort
4. You added a milestone step in your Jenkins pipeline but it does not seem to abort older runs as expected. Which of the following is the most likely cause?
medium
A. The pipeline is missing the agent block
B. The milestone step is placed after all stages have completed
C. The milestone label is not unique and is reused in multiple places
D. The Jenkins server is offline

Solution

  1. Step 1: Check milestone placement

    The milestone step is most likely placed after all stages have completed. This makes it ineffective because older runs finish before a newer run can reach the milestone to trigger aborts.
  2. Step 2: Evaluate other options

    Label reuse affects log clarity but not concurrency control (ordinals matter). Missing agent prevents runs entirely. Server offline stops everything.
  3. Final Answer:

    The milestone step is placed after all stages have completed -> Option B
  4. Quick Check:

    Milestone placement before completion critical = A [OK]
Hint: Place milestone before critical/protected sections [OK]
Common Mistakes:
  • Placing milestone after all stages
  • Blaming unrelated pipeline syntax
  • Assuming server offline causes milestone issues
5. You want to ensure that only the latest run of your Jenkins pipeline proceeds past the "Deploy" stage, aborting any previous runs stuck at that point. How should you use the milestone step to achieve this?
hard
A. Use milestone label: 'Deploy' only in the first stage
B. Place milestone label: 'Deploy' at the end of the Deploy stage
C. Place milestone label: 'Deploy' in every stage before Deploy
D. Place milestone label: 'Deploy' at the start of the Deploy stage

Solution

  1. Step 1: Identify where to place milestone for concurrency control

    To abort older runs before deploying, place the milestone step at the start of the Deploy stage so only the newest run proceeds.
  2. Step 2: Understand why other placements fail

    Placing milestone at the end or in other stages won't stop older runs before deployment. Using it only in the first stage doesn't control concurrency at Deploy.
  3. Final Answer:

    Place milestone label: 'Deploy' at the start of the Deploy stage -> Option D
  4. Quick Check:

    Milestone at stage start controls concurrency there [OK]
Hint: Put milestone at stage start to block old runs [OK]
Common Mistakes:
  • Placing milestone too late in the stage
  • Using milestone in unrelated stages
  • Not placing milestone at all
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard