Updating the logs collection from robot tests
[osm/devops.git] / jenkins / ci-pipelines / ci_stage_3.groovy
index 1e9748b..f4eaa10 100644 (file)
@@ -84,7 +84,7 @@ def run_robot_systest(stackName,tagName,testName,envfile=null,kubeconfig=null,cl
         sh(script: "touch ${tempdir}/env")
         envfile="${tempdir}/env"
     }
-    sh "docker run --network net${stackName} --env OSM_HOSTNAME=${stackName}_nbi --env-file ${envfile} -v ${clouds}:/etc/openstack/clouds.yaml -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports opensourcemano/tests:${tagName} -c -t ${testName}"
+    sh "docker run --network net${stackName} --env OSM_HOSTNAME=${stackName}_nbi --env PROMETHEUS_HOSTNAME=${stackName}_prometheus --env-file ${envfile} -v ${clouds}:/etc/openstack/clouds.yaml -v ${kubeconfig}:/root/.kube/config -v ${tempdir}:/robot-systest/reports opensourcemano/tests:${tagName} -c -t ${testName}"
     sh "cp ${tempdir}/* ."
     outputDirectory = sh(returnStdout: true, script: "pwd").trim()
     println ("Present Directory is : ${outputDirectory}")
@@ -101,6 +101,12 @@ def run_robot_systest(stackName,tagName,testName,envfile=null,kubeconfig=null,cl
     ])
 }
 
+def archive_logs(stackName) {
+    sh "docker service ls |grep \"${stackName}\"| awk '{print \$2}' | xargs -iy docker ps -af name=y  --format \"{{.ID}} {{.Names}}\" --no-trunc | awk '{ print \"sudo cp /var/lib/docker/containers/\"\$1\"/\"\$1\"-json.log \"\$2\".log\"}' | xargs -iy bash y "
+    sh "sudo chown jenkins: osm*.log"
+    archiveArtifacts artifacts: '*.log'
+}
+
 node("${params.NODE}") {
 
     sh 'env'
@@ -225,7 +231,7 @@ node("${params.NODE}") {
         if ( params.DO_BUILD ) {
             stage("Build") {
                 sh "make -C docker clean"
-                sh "make -C -j `nproc` docker Q= CMD_DOCKER_ARGS= TAG=${container_name} RELEASE=${params.RELEASE} REPOSITORY_BASE=${repo_base_url} REPOSITORY_KEY=${params.REPO_KEY_NAME} REPOSITORY=${params.REPO_DISTRO}"
+                sh "make -C docker -j `nproc` Q= CMD_DOCKER_ARGS= TAG=${container_name} RELEASE=${params.RELEASE} REPOSITORY_BASE=${repo_base_url} REPOSITORY_KEY=${params.REPO_KEY_NAME} REPOSITORY=${params.REPO_DISTRO}"
             }
         }
 
@@ -315,7 +321,8 @@ node("${params.NODE}") {
                     } //else {
                     run_systest(container_name,container_name,"openstack_stage_4",params.HIVE_VIM_1)
                     //}
-
+                    // Archive logs to containers_logs.txt
+                    archive_logs(container_name)
                     if ( ! currentBuild.result.equals('UNSTABLE') && ! currentBuild.result.equals('FAILURE')) {
                         stage_archive = keep_artifacts
                     } else {