From e1af1a862d8c2a5c410d9a4f6983f01ca0ff372c Mon Sep 17 00:00:00 2001 From: jerick Date: Mon, 2 Feb 2026 20:22:56 -0500 Subject: [PATCH] flush dns cache to get new dhcp lease on vm --- Jenkinsfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a4ecdfb..b1fd001 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,9 +102,12 @@ pipeline { def targetHost = "${templateHost}.lan" echo "Waiting for ${targetHost} (template hostname) to become available..." - // Wait up to 3 minutes for the machine to respond to ping - timeout(time: 3, unit: 'MINUTES') { + // Wait up to 5 minutes for the machine to respond to ping + timeout(time: 5, unit: 'MINUTES') { waitUntil { + // Flush DNS cache before each ping attempt + sh(script: "sudo systemd-resolve --flush-caches 2>/dev/null || sudo resolvectl flush-caches 2>/dev/null || sudo nscd -i hosts 2>/dev/null || true", returnStatus: true) + def result = sh( script: "ping -c 1 ${targetHost} > /dev/null 2>&1", returnStatus: true