Pipeline - while loop causes performance issue

Article ID:230610847
1 minute readKnowledge base

Issue

  • Jenkins UI is running incredibly slow

  • Pipeline Stage View UI is not responding or running slowly

  • Pipeline Builds are never finishing

  • Loops are defined in the slow Pipeline.

Resolution

Try not to use use infinite while loops inside of Pipeline code. A better alternative would be a Retry + Sleep blocks.

This will eliminate the possibility of an endless cycle of a build because it will stop trying after a certain number of attempts. Additionally it ensures that a failure is recorded if the the looped step is unsuccessful.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.