From c1a589781a10682c3573146e31ceb3728e060c83 Mon Sep 17 00:00:00 2001 From: Michal Kovarik Date: Feb 04 2020 15:01:18 +0000 Subject: Add function to check Semaphore flags. C3I-68 --- diff --git a/vars/c3i.groovy b/vars/c3i.groovy index 6325a83..3598418 100644 --- a/vars/c3i.groovy +++ b/vars/c3i.groovy @@ -303,3 +303,24 @@ def archiveContainersLogs(String project) { } archiveArtifacts "logs/**" } + +/** + * Check flags on semaphore. + * @param flags Flags to be checked. + * @return true when all flags are in 'Up' state + */ +def checkSemaphore(String ... flags) { + def failed = false + flags.each { + if (failed) { + return + } + def out = sh script: "curl http://internal.status.redhat.com/api/v1/components?name=${it}", returnStdout: true + def json_out = readJSON(text: out) + if (json_out.data[0]?.status_name != "Up") { + echo "${it} is not up" + failed = true + } + } + return !failed +}