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/3scale-api-security-with-oidc.groovy |  112 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 60 insertions(+), 52 deletions(-)

diff --git a/tests/jenkins/openshift-service-mesh-lab.groovy b/tests/jenkins/3scale-api-security-with-oidc.groovy
similarity index 79%
copy from tests/jenkins/openshift-service-mesh-lab.groovy
copy to tests/jenkins/3scale-api-security-with-oidc.groovy
index 243c75d..7ae1e32 100644
--- a/tests/jenkins/openshift-service-mesh-lab.groovy
+++ b/tests/jenkins/3scale-api-security-with-oidc.groovy
@@ -2,13 +2,13 @@
 // CloudForms
 def opentlc_creds = 'b93d2da4-c2b7-45b5-bf3b-ee2c08c6368e'
 def opentlc_admin_creds = '73b84287-8feb-478a-b1f2-345fd0a1af47'
-def cf_uri = 'https://labs.opentlc.com'
-def cf_group = 'opentlc-access-cicd'
+def cf_uri = 'https://rhpds.redhat.com'
+def cf_group = 'rhpds-access-cicd'
 // IMAP
 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
@@ -20,20 +20,25 @@
 // state variables
 def guid=''
 def openshift_location = ''
-//def ssh_location = ''
-//def ssh_p = ''
-
 
 // Catalog items
 def choices = [
-    'OPENTLC OpenShift Labs / OpenShift Service Mesh Lab',
-    'DevOps Team Development / DEV - OpenShift Service Mesh Lab',
+    'Multi-product Demos / 3Scale API Security with OIDC',
 ].join("\n")
 
 def region_choice = [
-    'na_sandboxes_gpte',
-    'apac_sandboxes_gpte',
-    'emea_sandboxes_gpte',
+    'global_gpte',
+].join("\n")
+
+def nodes_choice = [
+    '3',
+    '1',
+    '2',    
+    '4',
+    '5',
+    '6',
+    '7',
+    '8',
 ].join("\n")
 
 pipeline {
@@ -56,8 +61,13 @@
         )
         choice(
             choices: region_choice,
-            description: 'Region',
+            description: 'Catalog item',
             name: 'region',
+        )
+        choice(
+            choices: nodes_choice,
+            description: 'Number of Nodes',
+            name: 'nodes',
         )
     }
 
@@ -77,6 +87,15 @@
                     def catalog = params.catalog_item.split(' / ')[0].trim()
                     def item = params.catalog_item.split(' / ')[1].trim()
                     def region = params.region.trim()
+                    def nodes = params.nodes.trim()
+                    def cfparams = [
+                        'check=t',
+                        'expiration=14',
+                        'runtime=8',
+                        'quotacheck=t',
+                        "region=${region}",
+                        "nodes=${nodes}",
+                    ].join(',').trim()
                     echo "'${catalog}' '${item}'"
                     guid = sh(
                         returnStdout: true,
@@ -85,7 +104,7 @@
                           -c '${catalog}' \
                           -i '${item}' \
                           -G '${cf_group}' \
-                          -d 'expiration=6,runtime=8,region=${region}'
+                          -d '${cfparams}' \
                         """
                     ).trim()
 
@@ -93,31 +112,30 @@
                 }
             }
         }
-        /* Skip this step because sometimes the completed email arrives
-         before the 'has started' email */
+        // 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',
+                git url: 'https://github.com/sborenst/ansible_agnostic_deployer',
                     branch: 'development'
-
 
                 sh """./tests/jenkins/downstream/poll_email.py \
                     --server '${imap_server}' \
                     --guid ${guid} \
-                    --timeout 20 \
+                    --timeout 30 \
                     --filter 'has started'"""
             }
         }
-        
-        stage('Wait for last email and parse SSH location') {
+
+        stage('Wait for last email and parse OpenShift and App location') {
             environment {
                 credentials=credentials("${imap_creds}")
             }
             steps {
-                git url: 'https://github.com/redhat-cop/agnosticd',
+                git url: 'https://github.com/sborenst/ansible_agnostic_deployer',
                     branch: 'development'
 
                 script {
@@ -127,26 +145,15 @@
                           ./tests/jenkins/downstream/poll_email.py \
                           --server '${imap_server}' \
                           --guid ${guid} \
-                          --timeout 100 \
+                          --timeout 150 \
                           --filter 'has completed'
                         """
                     ).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 =~ /Connect to the shared cluster by pointing your web browser to <a href="(https:\/\/master\.[^"]+)/
+                        openshift_location = m[0][1]
+                        echo "openshift_location = '${openshift_location}'"
                     } catch(Exception ex) {
                         echo "Could not parse email:"
                         echo email
@@ -156,20 +163,6 @@
                 }
             }
         }
-
-//        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('Confirm before retiring') {
             when {
@@ -220,7 +213,7 @@
         }
         stage('Wait for deletion email') {
             steps {
-                git url: 'https://github.com/redhat-cop/agnosticd',
+                git url: 'https://github.com/sborenst/ansible_agnostic_deployer',
                     branch: 'development'
 
                 withCredentials([usernameColonPassword(credentialsId: imap_creds, variable: 'credentials')]) {
@@ -249,6 +242,21 @@
                 export DEBUG=true
                 ./opentlc/delete_svc_guid.sh '${guid}'
                 """
+            }
+
+            /* 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} \
+                    "bin/logs.sh ${guid}" || true
+                """.trim()
+                )
             }
 
             withCredentials([usernameColonPassword(credentialsId: imap_creds, variable: 'credentials')]) {
@@ -282,4 +290,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3