This article explains essential Jenkins pipeline options like timeout, skipDefaultCheckout, and retry for effective pipeline configuration.
In this article, we delve into several pipeline options available for configuring your Jenkins pipelines. Although Jenkins offers many configuration options, we’ll focus on three essential ones: timeout, skipDefaultCheckout, and retry. For additional details, refer to the official Jenkins documentation.
Below is an example that demonstrates the timeout property in action. In this configuration, the pipeline is set to time out after 1 minute. The first stage includes a sleep command lasting 70 seconds, intentionally exceeding the timeout limit and causing the build to abort.
The console output below confirms that the pipeline attempted to execute the sleep command for 70 seconds. Since the timeout is set to one minute, the build is aborted once the timeout is exceeded:
Copy
Ask AI
90f4fcfb..7bae46b main -> mainC:\Users\sanje\Documents\Jenkins-demo> git add .C:\Users\sanje\Documents\Jenkins-demo> git co
The output confirms that the pipeline’s sleep command exceeded the timeout threshold, resulting in the build being terminated. This behavior underscores the importance of the timeout option in preventing indefinitely running builds and preserving system resources.
Configuring the appropriate pipeline options in Jenkins provides several benefits:
Pipeline Option
Purpose
Example Use Case
timeout
Limits build duration to avoid runaway builds
Prevents a build from running longer than expected
skipDefaultCheckout
Disables automatic source code checkout
Allows manual handling of source checkout
retry
Automatically retries a failing build
Increases reliability by rerunning transient failures
By effectively managing build durations, source code checkouts, and retry behaviors, you can optimize your CI/CD pipelines to suit your project’s requirements.
Be cautious when setting timeout values and retry counts. Overly aggressive values may lead to premature terminations or masking underlying build issues.