Software⏱️ 2 min read📅 2026-05-31

How to Fix: How to add a timeout step to Jenkins Pipeline

Configure Jenkins Multi Branch Pipeline to set a timeout step after 20 minutes.

Quick Answer: Use the `timeout` parameter in the `agent` section of your pipeline configuration, e.g. `agent { docker: 'maven' } timeout(20 minutes)

When using a free style project in a Jenkins Multi Branch Pipeline Project, you might be wondering how to set a timeout step similar to the one used in a free style project. The issue arises from the fact that multi branch pipelines are designed to run sequentially and do not have an explicit timeout mechanism.

🔍 Why This Happens

  • [Cause]

🛠️ Step-by-Step Verified Fixes

Method 1: Using the 'timeout' Parameter

  1. Step 1: In your Jenkinsfile, add the 'timeout' parameter to your pipeline script.

Method 2: Using a Scripted Pipeline

  1. Step 1: In your Jenkinsfile, use the 'timeout' function to set a timeout for your pipeline.

💡 Conclusion

By implementing one of these methods, you can effectively add a timeout step to your Jenkins Multi Branch Pipeline Project and ensure that builds are aborted after a specified time if not concluded.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions