From 6087ddba5f593d2e83fc1fac980f4a006ad76686 Mon Sep 17 00:00:00 2001 From: Michal Kovarik Date: Dec 18 2019 08:26:32 +0000 Subject: Add archiveContainersLogs method Archives logs from all containers in selected openshift project. --- diff --git a/vars/c3i.groovy b/vars/c3i.groovy index 664c1ed..79bb0b5 100644 --- a/vars/c3i.groovy +++ b/vars/c3i.groovy @@ -285,3 +285,21 @@ def sendResultToMessageBus( echo 'Failed to sent the test result to ResultsDB.' } } + +/** + * Send message with container testing results. + * @param project Openshift project with pods logs to archive. + */ +def archiveContainersLogs(String project) { + dir('logs'){ + echo "Gathering logs from Openshift project ${project}" + openshift.withCluster() { + openshift.withProject(project) { + openshift.selector('pods').withEach { + writeFile(file: it.name().minus('pod/'), text: openshift.raw("logs --all-containers ${it.name()}").out) + } + } + } + } + archiveArtifacts "logs/**" +}