Jenkins Pipeline and External API Integration: Idempotency during retry(N) execution
0 reputation · 25 Jun 2026, 23:20 UTC
The retry(N) step in Jenkins Pipeline is designed to re-execute a block of code upon failure. However, this mechanism does not track side effects or state changes that occurred during previous attempts within the same block.
When integrating Jenkins with external systems—such as REST APIs or databases—a failure occurring after a write operation but before the step completes results in the write being issued again on the next retry. This creates a risk of duplicate records or inconsistent state if the external system does not natively support idempotency.
Currently, Jenkins does not provide a built-in way to generate idempotency keys or track successful external writes across retry attempts, leaving the deduplication logic entirely to the pipeline script or the target system.
- Is there a documented method to maintain a persistent state for a specific
retryblock to skip already-completed write operations? - Should this deduplication logic be handled via a dedicated plugin, or is the current design intended to rely exclusively on external system idempotency?