Removing REPO from the per-patch voltha-test

Change-Id: Ia8ff7324ed49419c8e6daa31cb60a2c3ea261b34
diff --git a/jjb/pipeline/voltha-bbsim-tests.groovy b/jjb/pipeline/voltha-bbsim-tests.groovy
index 509e7ca..cbf9e81 100644
--- a/jjb/pipeline/voltha-bbsim-tests.groovy
+++ b/jjb/pipeline/voltha-bbsim-tests.groovy
@@ -26,7 +26,7 @@
     timeout(time: 90, unit: 'MINUTES')
   }
   environment {
-    PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+    PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
     VOLTHA_LOG_LEVEL="DEBUG"
     FANCY=0
     WITH_SIM_ADAPTERS="n"
@@ -36,37 +36,61 @@
   }
 
   stages {
-
-    stage('Repo') {
+    stage('Clone kind-voltha') {
       steps {
-        step([$class: 'WsCleanup'])
-        checkout(changelog: false, \
-          poll: false,
-          scm: [$class: 'RepoScm', \
-            manifestRepositoryUrl: "${params.manifestUrl}", \
-            manifestBranch: "${params.branch}", \
-            currentBranch: true, \
-            destinationDir: 'voltha', \
-            forceSync: true,
-            resetFirst: true, \
-            quiet: true, \
-            jobs: 4, \
-            showAllChanges: true] \
-          )
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/kind-voltha",
+            refspec: "${kindVolthaChange}"
+          ]],
+          branches: [[ name: "master", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
       }
     }
-    stage('Patch') {
+    stage('Clone voltha-system-tests') {
       steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/voltha-system-tests",
+            refspec: "${volthaSystemTestsChange}"
+          ]],
+          branches: [[ name: "${branch}", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
+      }
+    }
+    stage('Download Patch') {
+      steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/${gerritProject}",
+            refspec: "${gerritRefspec}"
+          ]],
+          branches: [[ name: "${branch}", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gerritProject}"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
         sh """
-           pushd voltha
-           if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ]
-           then
-             repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
-           else
-             echo "No patchset to download!"
-           fi
-           popd
-           """
+          pushd $WORKSPACE/${gerritProject}
+          echo "Currently on commit: \n"
+          git log -1 --oneline
+          popd
+          """
       }
     }
     stage('Create K8s Cluster') {
@@ -74,14 +98,14 @@
         sh """
            if [ "${branch}" != "master" ]; then
              echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
-             source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
            else
              echo "on master, using default settings for kind-voltha"
            fi
 
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            JUST_K8S=y ./voltha up
-           bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin"
+           bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
            """
       }
     }
@@ -90,20 +114,20 @@
       steps {
         sh """
            make-local () {
-             make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
+             make -C $WORKSPACE/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
            }
            if [ "${gerritProject}" = "pyvoltha" ]; then
-             make -C $WORKSPACE/voltha/pyvoltha/ dist
-             export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/
+             make -C $WORKSPACE/pyvoltha/ dist
+             export LOCAL_PYVOLTHA=$WORKSPACE/pyvoltha/
              make-local voltha-openonu-adapter
            elif [ "${gerritProject}" = "voltha-lib-go" ]; then
-             make -C $WORKSPACE/voltha/voltha-lib-go/ build
-             export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/
+             make -C $WORKSPACE/voltha-lib-go/ build
+             export LOCAL_LIB_GO=$WORKSPACE/voltha-lib-go/
              make-local voltha-go
              make-local voltha-openolt-adapter
            elif [ "${gerritProject}" = "voltha-protos" ]; then
-             make -C $WORKSPACE/voltha/voltha-protos/ build
-             export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/
+             make -C $WORKSPACE/voltha-protos/ build
+             export LOCAL_PROTOS=$WORKSPACE/voltha-protos/
              make-local voltha-go
              make-local voltha-openolt-adapter
              make-local voltha-openonu-adapter
@@ -112,7 +136,7 @@
              # Set and handle GOPATH and PATH
              export GOPATH=\${GOPATH:-$WORKSPACE/go}
              export PATH=\$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:\$GOPATH/bin
-             make -C $WORKSPACE/voltha/voltctl/ build
+             make -C $WORKSPACE/voltctl/ build
            elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|kind-voltha)\$ ]]; then
              make-local ${gerritProject}
            fi
@@ -125,7 +149,7 @@
         sh '''
            if [ "${branch}" != "master" ]; then
              echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
-             source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
            else
              echo "on master, using default settings for kind-voltha"
            fi
@@ -148,7 +172,7 @@
         sh '''
            if [ "${branch}" != "master" ]; then
              echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
-             source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
            else
              echo "on master, using default settings for kind-voltha"
            fi
@@ -196,7 +220,7 @@
            done
 
            if [ "${gerritProject}" = "voltha-helm-charts" ]; then
-             export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
+             export CHART_PATH=$WORKSPACE/voltha-helm-charts
              export VOLTHA_CHART=\$CHART_PATH/voltha
              export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
              export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
@@ -206,15 +230,15 @@
            fi
 
            if [ "${gerritProject}" = "voltctl" ]; then
-             export VOLTCTL_VERSION=$(cat $WORKSPACE/voltha/voltctl/VERSION)
-             cp $WORKSPACE/voltha/voltctl/voltctl $WORKSPACE/voltha/kind-voltha/bin/voltctl
-             md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
+             export VOLTCTL_VERSION=$(cat $WORKSPACE/voltctl/VERSION)
+             cp $WORKSPACE/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
+             md5sum $WORKSPACE/kind-voltha/bin/voltctl
            fi
 
            printenv
            kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
 
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            ./voltha up
 
            # $NAME-env.sh contains the environment we used
@@ -236,7 +260,7 @@
              TARGET=functional-single-kind
            fi
 
-           make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
+           make -C $WORKSPACE/voltha-system-tests \$TARGET || true
            '''
       }
     }
@@ -247,7 +271,7 @@
       }
       steps {
         sh '''
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            source $NAME-env.sh
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -276,7 +300,7 @@
              TARGET=functional-single-kind-dt
            fi
 
-           make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
+           make -C $WORKSPACE/voltha-system-tests \$TARGET || true
            '''
       }
     }
@@ -287,7 +311,7 @@
       }
       steps {
         sh '''
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            source $NAME-env.sh
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -316,7 +340,7 @@
              TARGET=functional-single-kind-tt
            fi
 
-           make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
+           make -C $WORKSPACE/voltha-system-tests \$TARGET || true
            '''
       }
     }
@@ -326,7 +350,7 @@
     always {
       sh '''
          set +e
-         cp $WORKSPACE/voltha/kind-voltha/install-$NAME.log $WORKSPACE/
+         cp $WORKSPACE/kind-voltha/install-$NAME.log $WORKSPACE/
          kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
          kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
          kubectl get nodes -o wide
@@ -335,7 +359,7 @@
 
          sync
          pkill kail || true
-         md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
+         md5sum $WORKSPACE/kind-voltha/bin/voltctl
 
          ## Pull out errors from log files
          extract_errors_go() {
diff --git a/jjb/pipeline/voltha-scale-test.groovy b/jjb/pipeline/voltha-scale-test.groovy
index ad25bde..ee224d4 100644
--- a/jjb/pipeline/voltha-scale-test.groovy
+++ b/jjb/pipeline/voltha-scale-test.groovy
@@ -106,7 +106,10 @@
       steps {
         checkout([
           $class: 'GitSCM',
-          userRemoteConfigs: [[ url: "https://gerrit.opencord.org/kind-voltha", ]],
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/kind-voltha",
+            refspec: "${kindVolthaChange}"
+          ]],
           branches: [[ name: "master", ]],
           extensions: [
             [$class: 'WipeWorkspace'],
@@ -114,21 +117,16 @@
             [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
           ],
         ])
-        script {
-          sh(script:"""
-          if [ '${kindVolthaChange}' != '' ] ; then
-          cd $WORKSPACE/kind-voltha;
-          git fetch https://gerrit.opencord.org/kind-voltha ${kindVolthaChange} && git checkout FETCH_HEAD
-          fi
-          """)
-        }
       }
     }
     stage('Clone voltha-system-tests') {
       steps {
         checkout([
           $class: 'GitSCM',
-          userRemoteConfigs: [[ url: "https://gerrit.opencord.org/voltha-system-tests", ]],
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/voltha-system-tests",
+            refspec: "${volthaSystemTestsChange}"
+          ]],
           branches: [[ name: "${release}", ]],
           extensions: [
             [$class: 'WipeWorkspace'],
@@ -136,14 +134,6 @@
             [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
           ],
         ])
-        script {
-          sh(script:"""
-            if [ '${volthaSystemTestsChange}' != '' ] ; then
-              cd $WORKSPACE/voltha-system-tests;
-              git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
-            fi
-            """)
-        }
       }
     }
     stage('Deploy common infrastructure') {
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index bf2ed71..26690cb 100644
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -230,6 +230,8 @@
     name: 'verify_{project}_sanity-test{name-extension}'
     override-branch: '$GERRIT_BRANCH'
     sandbox: true
+    volthaSystemTestsChange: ''
+    kindVolthaChange: ''
 
     description: |
       <!-- Managed by Jenkins Job Builder -->
@@ -253,11 +255,6 @@
           description: 'Name of the Jenkins node to run the job on'
 
       - string:
-          name: manifestUrl
-          default: '{gerrit-server-url}/{voltha-test-manifest-repo}'
-          description: 'URL to the repo manifest'
-
-      - string:
           name: branch
           default: '{override-branch}'
           description: 'Name of the branch to use'
@@ -268,20 +265,25 @@
           description: 'Name of the Gerrit project'
 
       - string:
-          name: gerritChangeNumber
-          default: '$GERRIT_CHANGE_NUMBER'
-          description: 'Changeset number in Gerrit'
-
-      - string:
-          name: gerritPatchsetNumber
-          default: '$GERRIT_PATCHSET_NUMBER'
-          description: 'PatchSet number in Gerrit'
+          name: gerritRefspec
+          default: '$GERRIT_REFSPEC'
+          description: 'PatchSet REFSPEC in Gerrit, example value: "refs/changes/79/18779/13"'
 
       - string:
           name: extraHelmFlags
           default: ''
           description: 'Helm flags to pass to ./voltha up'
 
+      - string:
+          name: volthaSystemTestsChange
+          default: '{volthaSystemTestsChange}'
+          description: 'Download a change for gerrit in the voltha-system-tests repo, example value: "refs/changes/79/18779/13"'
+
+      - string:
+          name: kindVolthaChange
+          default: '{kindVolthaChange}'
+          description: 'Download a change for gerrit in the kind-voltha repo, example value: "refs/changes/32/19132/1"'
+
     project-type: pipeline
     concurrent: true