Refactor java jobs

Change-Id: I33de2951f249c5d5816c2b2ab1512c0c5b0c5b4f
Issue-ID: CIMAN-187
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
diff --git a/jjb/global-templates-java.yaml b/jjb/global-templates-java.yaml
index 03653d8..29a5c29 100644
--- a/jjb/global-templates-java.yaml
+++ b/jjb/global-templates-java.yaml
@@ -1,5 +1,5 @@
 ---
-- job-template:
+- job-template: &verify_java_defaults
     # Job template for Java verify jobs
     #
     # The purpose of this job template is to run:
@@ -14,6 +14,7 @@
     concurrent: true
     node: '{build-node}'
     pattern: '**'
+    pom:
 
     properties:
       - infra-properties:
@@ -53,6 +54,7 @@
           settings-file: '{mvn-settings}'
       - maven-target:
           maven-version: '{maven-version}'
+          pom: '{obj:pom}'
           goals: 'clean install -B
             -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn {mvn-params}'
           settings: '{mvn-settings}'
@@ -77,49 +79,8 @@
     # Required Variables:
     #     branch:    git branch (eg. stable/lithium or master)
 
+    <<: *verify_java_defaults
     name: '{project-name}-{stream}-verify-java-checkstyle'
-    project-type: freestyle
-    concurrent: true
-    node: '{build-node}'
-    properties:
-      - infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-    parameters:
-      - infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          refspec: 'refs/heads/{branch}'
-          artifacts: '{archive-artifacts}'
-      - maven-exec:
-          maven-version: '{maven-version}'
-      - maven-params:
-          mvn-params: '{mvn-params}'
-    scm:
-      - gerrit-trigger-scm:
-          refspec: '$GERRIT_REFSPEC'
-          choosing-strategy: 'gerrit'
-          submodule-recursive: '{submodule-recursive}'
-    wrappers:
-      - infra-wrappers:
-          build-timeout: '{build-timeout}'
-    triggers:
-      - gerrit-trigger-patch-submitted:
-          server: '{server-name}'
-          project: '{project}'
-          branch: '{branch}'
-          files: '**'
-    builders:
-      - provide-maven-settings:
-          global-settings-file: 'global-settings'
-          settings-file: '{mvn-settings}'
-      - maven-target:
-          maven-version: '{maven-version}'
-          goals: 'clean install -B
-            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn {mvn-params}'
-          settings: '{mvn-settings}'
-          settings-type: cfp
-          global-settings: 'global-settings'
-          global-settings-type: cfp
     publishers:
       - infra-shiplogs:
           maven-version: '{maven-version}'
@@ -139,60 +100,9 @@
     #     pattern:   ant file-path pattern relative to the workspace used to
     #                trigger the job
 
+    <<: *verify_java_defaults
     name: '{project-name}-{stream}-{subproject}-verify-java'
 
-    project-type: freestyle
-    concurrent: true
-    node: '{build-node}'
-
-    properties:
-      - infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-
-    parameters:
-      - infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          refspec: 'refs/heads/{branch}'
-          artifacts: '{archive-artifacts}'
-      - maven-exec:
-          maven-version: '{maven-version}'
-
-    scm:
-      - gerrit-trigger-scm:
-          refspec: '$GERRIT_REFSPEC'
-          choosing-strategy: 'gerrit'
-          submodule-recursive: '{submodule-recursive}'
-
-    wrappers:
-      - infra-wrappers:
-          build-timeout: '{build-timeout}'
-
-    triggers:
-      - gerrit-trigger-patch-submitted:
-          server: '{server-name}'
-          project: '{project}'
-          branch: '{branch}'
-          files: '{pattern}'
-
-    builders:
-      - provide-maven-settings:
-          global-settings-file: 'global-settings'
-          settings-file: '{mvn-settings}'
-      - maven-target:
-          maven-version: '{maven-version}'
-          pom: '{pom}'
-          goals: 'clean install -B
-            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
-          settings: '{mvn-settings}'
-          settings-type: cfp
-          global-settings: 'global-settings'
-          global-settings-type: cfp
-
-    publishers:
-      - infra-shiplogs:
-          maven-version: '{maven-version}'
-
 - job-template:
     # Job template for Java daily release jobs
     #
@@ -656,7 +566,7 @@
           maven-version: '{maven-version}'
 
 
-- job-template:
+- job-template: &merge_java_defaults
     # Job template for Java merge jobs
     #
     # The purpose of this job template is to run:
@@ -669,204 +579,9 @@
 
     project-type: freestyle
     node: '{build-node}'
-
-    properties:
-      - infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-
-    parameters:
-      - infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          refspec: 'refs/heads/{branch}'
-          artifacts: '{archive-artifacts}'
-      - maven-exec:
-          maven-version: '{maven-version}'
-
-    scm:
-      - gerrit-trigger-scm:
-          refspec: ''
-          choosing-strategy: 'default'
-          submodule-recursive: '{submodule-recursive}'
-
-    wrappers:
-      - infra-wrappers:
-          build-timeout: '{build-timeout}'
-
-    triggers:
-      - gerrit-trigger-patch-merged:
-          server: '{server-name}'
-          project: '{project}'
-          branch: '{branch}'
-          files: '**'
-
-    builders:
-      - provide-maven-settings:
-          global-settings-file: 'global-settings'
-          settings-file: '{mvn-settings}'
-      - maven-target:
-          maven-version: '{maven-version}'
-          goals: 'clean deploy -B
-            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
-          settings: '{mvn-settings}'
-          settings-type: cfp
-          global-settings: 'global-settings'
-          global-settings-type: cfp
-
-    publishers:
-      - infra-shiplogs:
-          maven-version: '{maven-version}'
-
-- job-template:
-    # Job template for Java merge jobs based on
-    #   '{project-name}-{stream}-merge-java'
-    # The purpose of this job template is to run:
-    # 1. maven clean deploy
-    #
-    # This project supports maven properties.
-    #
-    # Required Variables:
-    #     branch:    git branch (eg. stable/lithium or master)
-    #     maven-properties: properties passed to maven
-
-    name: '{project-name}-{stream}-merge-properties-java'
-
-    project-type: freestyle
-    node: '{build-node}'
-
-    properties:
-      - infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-
-    parameters:
-      - infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          refspec: 'refs/heads/{branch}'
-          artifacts: '{archive-artifacts}'
-      - maven-exec:
-          maven-version: '{maven-version}'
-
-    scm:
-      - gerrit-trigger-scm:
-          refspec: ''
-          choosing-strategy: 'default'
-          submodule-recursive: '{submodule-recursive}'
-
-    wrappers:
-      - infra-wrappers:
-          build-timeout: '{build-timeout}'
-
-    triggers:
-      - gerrit-trigger-patch-merged:
-          server: '{server-name}'
-          project: '{project}'
-          branch: '{branch}'
-          files: '**'
-
-    builders:
-      - provide-maven-settings:
-          global-settings-file: 'global-settings'
-          settings-file: '{mvn-settings}'
-      - maven-target:
-          maven-version: '{maven-version}'
-          goals: 'clean deploy -B
-            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
-          settings: '{mvn-settings}'
-          settings-type: cfp
-          global-settings: 'global-settings'
-          global-settings-type: cfp
-          properties: '{obj:mvn_properties}'
-
-    publishers:
-      - infra-shiplogs:
-          maven-version: '{maven-version}'
-
-- job-template:
-    # Job template for Java merge jobs that takes a maven template
-    #
-    # The purpose of this job template is to run:
-    # 1. maven clean deploy -P {mvn-profile}
-    #
-    # Required Variables:
-    #     branch:    git branch (eg. stable/lithium or master)
-
-    name: '{project-name}-{stream}-merge-profile-java'
-
-    project-type: freestyle
-    node: '{build-node}'
-
-    properties:
-      - infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-
-    parameters:
-      - infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          refspec: 'refs/heads/{branch}'
-          artifacts: '{archive-artifacts}'
-      - maven-exec:
-          maven-version: '{maven-version}'
-
-    scm:
-      - gerrit-trigger-scm:
-          refspec: ''
-          choosing-strategy: 'default'
-          submodule-recursive: '{submodule-recursive}'
-
-    wrappers:
-      - infra-wrappers:
-          build-timeout: '{build-timeout}'
-
-    triggers:
-      - gerrit-trigger-patch-merged:
-          server: '{server-name}'
-          project: '{project}'
-          branch: '{branch}'
-          files: '{files}'
-
-    builders:
-      - provide-maven-settings:
-          global-settings-file: 'global-settings'
-          settings-file: '{mvn-settings}'
-
-      - docker-login
-
-      - maven-target:
-          maven-version: '{maven-version}'
-          goals: 'clean deploy -P {mvn-profile} -B
-            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
-          settings: '{mvn-settings}'
-          settings-type: cfp
-          global-settings: 'global-settings'
-          global-settings-type: cfp
-          properties:
-            - docker.pull.registry=nexus3.onap.org:10001
-            - docker.push.registry=nexus3.onap.org:10003
-
-    publishers:
-      - infra-shiplogs:
-          maven-version: '{maven-version}'
-
-- job-template:
-    # Job template for Java merge jobs with POM not at the root
-    #
-    # The purpose of this job template is to run:
-    # 1. maven clean deploy
-    #
-    # This job supports subprojects.
-    #
-    # Required Variables:
-    #     branch:    git branch (eg. stable/lithium or master)
-    #     pom:       name/location of the pom.xml file relative to the workspace
-    #     pattern:   ant file-path pattern relative to the workspace used to
-    #                trigger the job
-
-    name: '{project-name}-{stream}-{subproject}-merge-java'
-
-    project-type: freestyle
-    node: '{build-node}'
+    pattern: '**'
+    pom:
+    mvn_properties: []
 
     properties:
       - infra-properties:
@@ -904,19 +619,83 @@
           settings-file: '{mvn-settings}'
       - maven-target:
           maven-version: '{maven-version}'
-          pom: '{pom}'
+          pom: '{obj:pom}'
           goals: 'clean deploy -B
             -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
           settings: '{mvn-settings}'
           settings-type: cfp
           global-settings: 'global-settings'
           global-settings-type: cfp
+          properties: '{obj:mvn_properties}'
 
     publishers:
       - infra-shiplogs:
           maven-version: '{maven-version}'
 
 - job-template:
+    # Job template for Java merge jobs based on
+    #   '{project-name}-{stream}-merge-java'
+    # The purpose of this job template is to run:
+    # 1. maven clean deploy
+    #
+    # This project supports maven properties.
+    #
+    # Required Variables:
+    #     branch:    git branch (eg. stable/lithium or master)
+    #     maven-properties: properties passed to maven
+
+    <<: *merge_java_defaults
+    name: '{project-name}-{stream}-merge-properties-java'
+
+- job-template:
+    # Job template for Java merge jobs that takes a maven template
+    #
+    # The purpose of this job template is to run:
+    # 1. maven clean deploy -P {mvn-profile}
+    #
+    # Required Variables:
+    #     branch:    git branch (eg. stable/lithium or master)
+
+    <<: *merge_java_defaults
+    name: '{project-name}-{stream}-merge-profile-java'
+
+    builders:
+      - provide-maven-settings:
+          global-settings-file: 'global-settings'
+          settings-file: '{mvn-settings}'
+
+      - docker-login
+
+      - maven-target:
+          maven-version: '{maven-version}'
+          goals: 'clean deploy -P {mvn-profile} -B
+            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
+          settings: '{mvn-settings}'
+          settings-type: cfp
+          global-settings: 'global-settings'
+          global-settings-type: cfp
+          properties:
+            - docker.pull.registry=nexus3.onap.org:10001
+            - docker.push.registry=nexus3.onap.org:10003
+
+- job-template:
+    # Job template for Java merge jobs with POM not at the root
+    #
+    # The purpose of this job template is to run:
+    # 1. maven clean deploy
+    #
+    # This job supports subprojects.
+    #
+    # Required Variables:
+    #     branch:    git branch (eg. stable/lithium or master)
+    #     pom:       name/location of the pom.xml file relative to the workspace
+    #     pattern:   ant file-path pattern relative to the workspace used to
+    #                trigger the job
+
+    <<: *merge_java_defaults
+    name: '{project-name}-{stream}-{subproject}-merge-java'
+
+- job-template:
     # Job template for Docker daily jobs
     #
     # The purpose of this job template is to run:
@@ -1612,7 +1391,6 @@
 
       - maven-docker-push-daily:
           maven-version: '{maven-version}'
-          pom: '{pom}'
           mvn-settings: '{mvn-settings}'
           pom: '{docker-pom}'
           # use default as mvn-profile if profile is not needed
@@ -1809,42 +1587,12 @@
     # Required Variables:
     #     branch:    git branch (eg. stable/lithium or master)
 
+    <<: *merge_java_defaults
     name: '{project-name}-{stream}-sdc-merge-java'
 
-    project-type: freestyle
     node: 'ubuntu1604-docker-8c-8g'
     build-timeout: 120
 
-    properties:
-      - infra-properties:
-          build-days-to-keep: '{build-days-to-keep}'
-
-    parameters:
-      - infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          refspec: 'refs/heads/{branch}'
-          artifacts: '{archive-artifacts}'
-      - maven-exec:
-          maven-version: '{maven-version}'
-
-    scm:
-      - gerrit-trigger-scm:
-          refspec: ''
-          choosing-strategy: 'default'
-          submodule-recursive: '{submodule-recursive}'
-
-    wrappers:
-      - infra-wrappers:
-          build-timeout: '{build-timeout}'
-
-    triggers:
-      - gerrit-trigger-patch-merged:
-          server: '{server-name}'
-          project: '{project}'
-          branch: '{branch}'
-          files: '**'
-
     builders:
       - provide-maven-settings:
           global-settings-file: 'global-settings'
@@ -1852,16 +1600,13 @@
 
       - docker-login
 
-      - maven-docker-push-daily-test:
+      - maven-docker-push-daily:
           maven-version: '{maven-version}'
           mvn-settings: '{mvn-settings}'
           pom: '{docker-pom}'
           # use default as mvn-profile if profile is not needed
           mvn-profile: '{mvn-profile}'
-
-    publishers:
-      - infra-shiplogs:
-          maven-version: '{maven-version}'
+          mvn-params: ''
 
 - job-template:
     # Job template for building & pushing docker images for AAI specific repos