From 33fc99134cf9441f64c8ad17eadc55b88e3fcee8 Mon Sep 17 00:00:00 2001
From: Dibyendu Jana <34668540+d-jana@users.noreply.github.com>
Date: Thu, 27 Feb 2020 17:00:21 +0100
Subject: [PATCH] Add new groovy files for 3 cloud native CIs and Babylon empty-config CI (#1004)

---
 tests/jenkins/rhel-8-new-features-for-exp-admins.groovy |   94 +++++++++++++++++-----------------------------
 1 files changed, 35 insertions(+), 59 deletions(-)

diff --git a/tests/jenkins/openshift-service-mesh-lab.groovy b/tests/jenkins/rhel-8-new-features-for-exp-admins.groovy
similarity index 78%
copy from tests/jenkins/openshift-service-mesh-lab.groovy
copy to tests/jenkins/rhel-8-new-features-for-exp-admins.groovy
index 243c75d..8fb73ed 100644
--- a/tests/jenkins/openshift-service-mesh-lab.groovy
+++ b/tests/jenkins/rhel-8-new-features-for-exp-admins.groovy
@@ -8,7 +8,7 @@
 def imap_creds = 'd8762f05-ca66-4364-adf2-bc3ce1dca16c'
 def imap_server = 'imap.gmail.com'
 // Notifications
-def notification_email = 'gucore@redhat.com'
+def notification_email = 'gpteinfrasev3@redhat.com'
 def rocketchat_hook = '5d28935e-f7ca-4b11-8b8e-d7a7161a013a'
 
 // SSH key
@@ -19,21 +19,16 @@
 
 // state variables
 def guid=''
-def openshift_location = ''
-//def ssh_location = ''
-//def ssh_p = ''
+def external_host = ''
 
 
 // Catalog items
 def choices = [
-    'OPENTLC OpenShift Labs / OpenShift Service Mesh Lab',
-    'DevOps Team Development / DEV - OpenShift Service Mesh Lab',
+    'OPENTLC Datacenter Infrastructure Labs / RHEL 8 New Features For Exp. Admins',		
 ].join("\n")
 
 def region_choice = [
-    'na_sandboxes_gpte',
-    'apac_sandboxes_gpte',
-    'emea_sandboxes_gpte',
+    'global_gpte',
 ].join("\n")
 
 pipeline {
@@ -85,7 +80,7 @@
                           -c '${catalog}' \
                           -i '${item}' \
                           -G '${cf_group}' \
-                          -d 'expiration=6,runtime=8,region=${region}'
+                          -d 'check=t,expiration=7,runtime=4,region=${region},quotacheck=t'
                         """
                     ).trim()
 
@@ -93,26 +88,9 @@
                 }
             }
         }
-        /* Skip this step because sometimes the completed email arrives
-         before the 'has started' email */
-        stage('Wait for first email') {
-            environment {
-                credentials=credentials("${imap_creds}")
-            }
-            steps {
-                git url: 'https://github.com/redhat-cop/agnosticd',
-                    branch: 'development'
-
-
-                sh """./tests/jenkins/downstream/poll_email.py \
-                    --server '${imap_server}' \
-                    --guid ${guid} \
-                    --timeout 20 \
-                    --filter 'has started'"""
-            }
-        }
         
-        stage('Wait for last email and parse SSH location') {
+        // This kind of CI send only one mail
+        stage('Wait to receive and parse email') {
             environment {
                 credentials=credentials("${imap_creds}")
             }
@@ -127,26 +105,16 @@
                           ./tests/jenkins/downstream/poll_email.py \
                           --server '${imap_server}' \
                           --guid ${guid} \
-                          --timeout 100 \
-                          --filter 'has completed'
+                          --timeout 30 \
+                          --filter 'is building'
                         """
                     ).trim()
 
                     try {
-                    	def m = email =~ /Openshift Master Console: (.*)/
-                    	openshift_location = m[0][1]
-                    	echo "Openshift Master Console: ${openshift_location}"
-                    
-//						m = email =~ /This cluster has authentication enabled. (.*)/
-//						echo "Cluster authentication:  ${m[0][1]}"
-                      
-//                    	m = email =~ /SSH Access: (.*)/
-//						ssh_location = m[0][1]
-//						echo "SSH Access: ${ssh_location}"
-						
-//						m = email =~ /SSH password: (.*)/
-//						ssh_p =��� m[0][1]
-//						echo "SSH password: ${ssh_p}"
+                    	def m = email =~ /External Hostname<\/TH><TD>(.*)/
+                    	def mm = email =~ /(.*)<\/TD><\/TR><TR><TH>Internal IP Address/
+                    	external_host = m[0][1].replaceAll("=","") + mm[0][1].replaceAll(" ","")
+                    	echo "External-Host='${external_host}'"
                     } catch(Exception ex) {
                         echo "Could not parse email:"
                         echo email
@@ -156,20 +124,13 @@
                 }
             }
         }
-
-//        stage('SSH') {
-//            steps {
-//                withCredentials([
-//                    sshUserPrivateKey(
-//                        credentialsId: ssh_creds,
-//                        keyFileVariable: 'ssh_key',
-//                        usernameVariable: 'ssh_username')
-//                ]) {
-//                    sh "ssh -o StrictHostKeyChecking=no -i ${ssh_key} ${ssh_location} w"
-//                    sh "ssh -o StrictHostKeyChecking=no -i ${ssh_key} ${ssh_location} oc version"
-//                }
-//            }
-//        }
+        
+        stage ('Wait to complete provision') {
+        	steps {
+				echo "Wait for 30 minutes for deployment to complete"
+				sleep 1800 // seconds
+			}
+		}
 
         stage('Confirm before retiring') {
             when {
@@ -251,6 +212,21 @@
                 """
             }
 
+            /* Print ansible logs */
+            withCredentials([
+                string(credentialsId: ssh_admin_host, variable: 'ssh_admin'),
+                sshUserPrivateKey(
+                    credentialsId: ssh_creds,
+                    keyFileVariable: 'ssh_key',
+                    usernameVariable: 'ssh_username')
+            ]) {
+                sh("""
+                    ssh -o StrictHostKeyChecking=no -i ${ssh_key} ${ssh_admin} \
+                    "find deployer_logs -name '*${guid}*log' | xargs cat"
+                """.trim()
+                )
+            }
+
             withCredentials([usernameColonPassword(credentialsId: imap_creds, variable: 'credentials')]) {
                 mail(
                     subject: "${env.JOB_NAME} (${env.BUILD_NUMBER}) failed GUID=${guid}",

--
Gitblit v1.9.3