From 748ef17e4222ea78f43d2ebee16389c7e7894ea3 Mon Sep 17 00:00:00 2001 From: Yug Gupta Date: Mon, 18 May 2020 18:44:07 +0530 Subject: [PATCH] ci: retry if no machine is immediately available To prevent the failure of job due to unavailability of a machine immediately, retry mechanism is used. If unable to reserve a machine, it will retry every 5 mins for 30 times to avoid job failure. Signed-off-by: Yug Gupta --- containerized-tests.groovy | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/containerized-tests.groovy b/containerized-tests.groovy index 8df934cd9..cb03545a1 100644 --- a/containerized-tests.groovy +++ b/containerized-tests.groovy @@ -13,12 +13,19 @@ node('cico-workspace') { } stage('reserve bare-metal machine') { - cico = sh( - script: "cico node get -f value -c hostname -c comment --retry-count ${cico_retries} --retry-interval ${cico_retry_interval}", - returnStdout: true - ).trim().tokenize(' ') - env.CICO_NODE = "${cico[0]}.ci.centos.org" - env.CICO_SSID = "${cico[1]}" + def firstAttempt = true + retry(30) { + if (!firstAttempt) { + sleep(time: 5, unit: "MINUTES") + } + firstAttempt = false + cico = sh( + script: "cico node get -f value -c hostname -c comment --retry-count ${cico_retries} --retry-interval ${cico_retry_interval}", + returnStdout: true + ).trim().tokenize(' ') + env.CICO_NODE = "${cico[0]}.ci.centos.org" + env.CICO_SSID = "${cico[1]}" + } } try {