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 <ygupta@redhat.com>
This commit is contained in:
Yug Gupta 2020-05-18 18:44:07 +05:30 committed by Niels de Vos
parent f6229ae237
commit 748ef17e42

View File

@ -13,6 +13,12 @@ node('cico-workspace') {
} }
stage('reserve bare-metal machine') { stage('reserve bare-metal machine') {
def firstAttempt = true
retry(30) {
if (!firstAttempt) {
sleep(time: 5, unit: "MINUTES")
}
firstAttempt = false
cico = sh( cico = sh(
script: "cico node get -f value -c hostname -c comment --retry-count ${cico_retries} --retry-interval ${cico_retry_interval}", script: "cico node get -f value -c hostname -c comment --retry-count ${cico_retries} --retry-interval ${cico_retry_interval}",
returnStdout: true returnStdout: true
@ -20,6 +26,7 @@ node('cico-workspace') {
env.CICO_NODE = "${cico[0]}.ci.centos.org" env.CICO_NODE = "${cico[0]}.ci.centos.org"
env.CICO_SSID = "${cico[1]}" env.CICO_SSID = "${cico[1]}"
} }
}
try { try {
stage('prepare bare-metal machine') { stage('prepare bare-metal machine') {