Define new parallel jenkins jobs for fabric-tna

parallelized execution of fabric-tna jobs running one profile plus architecture, each.

Shift from bash scripts to declarative pipeline.

Change-Id: I38c8f8e8c24e7b72e5025c56123e3a21717a600d
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index ba88535..042121c 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -28,6 +28,8 @@
     #  https://jenkins.onosproject.org/configure
     build-node: ubuntu16.04-basebuild-1c-1g
 
+    medium-build-node: ubuntu16.04-basebuild-4c-8g
+
     # Powerful node, this type of node should be used for bazel builds.
     bigger-build-node: ubuntu16.04-basebuild-8c-15g
 
diff --git a/jjb/repos/fabric-tna.yaml b/jjb/repos/fabric-tna.yaml
index 2c6e870..0b76702 100644
--- a/jjb/repos/fabric-tna.yaml
+++ b/jjb/repos/fabric-tna.yaml
@@ -15,9 +15,26 @@
       - 'fabric-tna-jobs':
             stream: 'main'
 
+    # Job matrix
+    profile:
+      - fabric
+      - fabric-int
+      - fabric-spgw
+      - fabric-spgw-int
+    arch:
+      - tna
+      - v1model
+    exclude:
+      - profile: fabric-int
+        arch: v1model
+      - profile: fabric-spgw
+        arch: v1model
+      - profile: fabric-spgw-int
+        arch: v1model
+
 - job-group:
     name: 'fabric-tna-jobs'
     jobs:
-      - 'fabric-tna-pr-verify'
-      - 'fabric-tna-postmerge'
+      - 'pr-verify-{profile}-{arch}'
+      - 'postmerge-{profile}-{arch}'
       - 'fabric-tna-linerate-tests'
diff --git a/jjb/templates/fabric-tna-jobs.yaml b/jjb/templates/fabric-tna-jobs.yaml
index 8e8db60..7da8b04 100644
--- a/jjb/templates/fabric-tna-jobs.yaml
+++ b/jjb/templates/fabric-tna-jobs.yaml
@@ -1,9 +1,9 @@
 ---
-# Run pull request verify job for fabric-tna
+# Run pull request verify job for each fabric profile and architecture
 
 - job-template:
-    id: 'fabric-tna-pr-verify'
-    name: 'fabric-tna-pr-verify'
+    id: 'pr-verify-{profile}-{arch}'
+    name: pr-verify-{profile}-{arch}
 
     description: |
       Created by {id} job-template from ci-management/jjb/templates/fabric-tna-jobs.yaml<br/>
@@ -18,17 +18,31 @@
       - github:
           url: 'https://github.com/{github-organization}/{project}'
 
-    node: '{bigger-build-node}'
-    project-type: freestyle
+    project-type: pipeline
     concurrent: true
 
     parameters:
-      - onf-infra-parameters:
-          project: '{project}'
-          stream: '{stream}'
-          gerrit_project: 'not-a-gerrit-project'
+      - string:
+          name: buildNode
+          default: "{medium-build-node}"
+          description: "Name of the Jenkins executor node to run the job on."
+      - string:
+          name: sha1
+          default: "origin/{stream}"
+          description: "SHA string of the pull request commit to build. Populated by GitHUb Pull Request Builder."
+      - string:
+          name: profile
+          default: "{profile}"
+          description: "Profile to build and test."
+      - string:
+          name: architecture
+          default: "{arch}"
+          description: "P4 architecture to use (v1model or tna)."
 
-    scm:
+    # Run pipeline that is checked-in in the same PR we want to verify.
+    pipeline-scm:
+      script-path: ".jenkins/Jenkinsfile"
+      scm:
       - onf-infra-github-ssh-scm:
           github-organization: '{github-organization}'
           project: '{project}'
@@ -39,7 +53,7 @@
       - onf-infra-github-pr-trigger:
           github_pr_org_list: '{obj:github_pr_org_list}'
           github_pr_auth_id: '{github_pr_auth_id}'
-          status_context: 'fabric-tna-pr-verify'
+          status_context: 'pr-verify-{profile}-{arch}'
 
     wrappers:
       - lf-infra-wrappers:
@@ -65,22 +79,9 @@
               credential-id: codecov-fabric-tna
               variable: CODECOV_TOKEN
 
-    builders:
-      - shell: !include-raw-escape: ../shell/docker-login.sh
-      # For now, let the actual job script evolve in the repo. We can make that
-      # a pipeline later.
-      - shell: |
-            bash .jenkins/pr_verify.sh
-
-    publishers:
-      - onf-infra-wscleanup-publisher
-      - archive:
-          artifacts: '**/*.log,**/*.pcap,**/*.json'
-          excludes: 'tmp/**/*'
-
 - job-template:
-    id: 'fabric-tna-postmerge'
-    name: 'fabric-tna-postmerge'
+    id: 'postmerge-{profile}-{arch}'
+    name: 'postmerge-{profile}-{arch}'
 
     description: |
       Created by {id} job-template from ci-management/jjb/templates/fabric-tna-jobs.yaml<br/>
@@ -95,8 +96,7 @@
       - github:
           url: 'https://github.com/{github-organization}/{project}'
 
-    node: '{bigger-build-node}'
-    project-type: freestyle
+    project-type: pipeline
     concurrent: true
 
     parameters:
@@ -105,9 +105,22 @@
           repo-url: 'git@github.com:{github-organization}/{project}.git'
           branch: '{stream}'
           sha1: '{stream}'
+      - string:
+          name: buildNode
+          default: "{medium-build-node}"
+          description: "Name of the Jenkins executor node to run the job on."
+      - string:
+          name: profile
+          default: "{profile}"
+          description: "Profile to be built and tested."
+      - string:
+          name: architecture
+          default: "{arch}"
+          description: "P4 architecture to use (v1model or tna)."
 
-
-    scm:
+    pipeline-scm:
+      script-path: ".jenkins/Jenkinsfile"
+      scm:
       - onf-infra-github-ssh-scm:
           github-organization: '{github-organization}'
           project: '{project}'
@@ -143,23 +156,6 @@
               credential-id: codecov-fabric-tna
               variable: CODECOV_TOKEN
 
-    builders:
-      - github-notifier
-      - shell: !include-raw-escape: ../shell/docker-login.sh
-      # For now, let the actual job script evolve in the repo. We can make that
-      # a pipeline later.
-      - shell: |
-            bash .jenkins/postmerge.sh
-
-    publishers:
-      - github-notifier
-      - onf-infra-wscleanup-publisher
-      - archive:
-          # Preserve the build log so we can compare the resources between the main
-          # branch and the new pull request.
-          artifacts: '**/*.log,**/*.json'
-          excludes: 'tmp/**/*'
-
 - job-template:
     id: 'fabric-tna-linerate-tests'
     name: 'fabric-tna-linerate-tests'