Using Jenkins Options Directive with Timeout and Retry
📖 Scenario: You are setting up a Jenkins pipeline to build a simple project. Sometimes the build step can take too long or fail temporarily. To handle this, you want to add controls to stop the build if it takes too long and retry the build if it fails.
🎯 Goal: Build a Jenkins pipeline script that uses the options directive to set a timeout of 5 minutes and retry the build step 2 times if it fails.
📋 What You'll Learn
Create a Jenkins pipeline with a
pipeline blockAdd an
options directive with timeout set to 5 minutesAdd
retry directive to retry the build step 2 timesInclude a simple
sh step that simulates a build commandPrint a message when the build starts
💡 Why This Matters
🌍 Real World
In real projects, builds can hang or fail temporarily. Using timeout and retry helps keep pipelines reliable and efficient.
💼 Career
DevOps engineers often configure Jenkins pipelines with options like timeout and retry to improve automation robustness.
Progress0 / 4 steps