fixing bugs in all api test pipeline script for helm deployment

Change-Id: Ie0398b29316341f2756a7d6b3c9bd3f1ddf43946
diff --git a/jjb/pipeline/autogeneration-api-test.groovy b/jjb/pipeline/all-xos-api-test-helm.groovy
similarity index 84%
rename from jjb/pipeline/autogeneration-api-test.groovy
rename to jjb/pipeline/all-xos-api-test-helm.groovy
index dbe3564..b0115f3 100644
--- a/jjb/pipeline/autogeneration-api-test.groovy
+++ b/jjb/pipeline/all-xos-api-test-helm.groovy
@@ -59,8 +59,8 @@
         stage('images') {
           steps {
             sh '''
-               pushd cord/automation-tools
-               ./developer/imagebuilder.py -f ../helm-charts/examples/api-test-images.yaml
+               pushd cord/automation-tools/developer
+               ./imagebuilder.py -f ../../helm-charts/examples/api-test-images.yaml
                popd
                '''
           }
@@ -129,7 +129,7 @@
             docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
             docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
             docker exec -i \$CORE_CONTAINER /bin/bash -c "xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosapitests.xtarget /opt/xos/core/models/core.xproto" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
-            SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /ospt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
+            SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
             export testname=_service_api.robot
             export library=_library.robot
             for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosserviceapitests.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done
@@ -142,23 +142,27 @@
           sh """
               pushd cord/test/cord-tester/src/test/cord-api/Tests
               CORE_CONTAINER=\$(docker ps | grep k8s_xos-core | awk '{print \$1}')
+              CHAM_CONTAINER=\$(docker ps | grep k8s_xos-chameleon | awk '{print \$1}')
+              XOS_CHAMELEON=\$(docker exec \$CHAM_CONTAINER ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
               export testname=_service_api.robot
               export library=_library.robot
               SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
               echo \$SERVICES
-              export SERVER_IP=xos-chameleon
+              export SERVER_IP=\$XOS_CHAMELEON
               export SERVER_PORT=9101
               export XOS_USER=xosadmin@opencord.org
               export XOS_PASSWD=\$(cat $WORKSPACE/cord/build/platform-install/credentials/xosadmin@opencord.org)
               cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
-              sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'xos-chameleon\'/\" RestApiProperties.py
+              sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'\$XOS_CHAMELEON\'/\" RestApiProperties.py
               sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
-              sed -i \"s/^\\(XOS_USER = \\).*/\\1\'xosadmin@opencord.org\'/\" RestApiProperties.py
-              sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'\$(cat $WORKSPACE/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
-              sed -i \"s/^\\(PASSWD = \\).*/\\1\'\$(cat $WORKSPACE/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
+              sed -i \"s/^\\(XOS_USER = \\).*/\\1\'admin@opencord.org\'/\" RestApiProperties.py
+              sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
+              sed -i \"s/^\\(PASSWD = \\).*/\\1\'letmein\'/\" RestApiProperties.py
               cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
               pybot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice -e ControllerUser XOSCoreAPITests.robot  || true
-              for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
+              if [[ "$GERRIT_PROJECT" =~ ^(rcord|vrouter|vsg|vtn|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|kubernetes-service)\$ ]]; then
+                  for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
+              fi
               popd
             """
             }
@@ -187,7 +191,7 @@
                 kubectl get pods --all-namespaces
                 helm list
             '''
-            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
+            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "suchitra@opennetworking.org, you@opennetworking.org, kailash@opennetworking.org", sendToIndividuals: false])
         }
     }
 }