Publishing ONOS images in docker when merges happen

Change-Id: I936edfe5375ca583c264d6b644cbc2d74b6e7aca
diff --git a/jjb/onos/onos-verify.yaml b/jjb/onos/onos-verify.yaml
index a50a080..440ba62 100644
--- a/jjb/onos/onos-verify.yaml
+++ b/jjb/onos/onos-verify.yaml
@@ -231,7 +231,7 @@
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           basedir: "$WORKSPACE"
 
-- docker_build_boiler_plate: &docker_build_boiler_plate
+- docker_release_build_boiler_plate: &docker_release_build_boiler_plate
     name: release_build_boiler_plate
 
     concurrent: true
@@ -260,6 +260,48 @@
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           basedir: "$WORKSPACE"
 
+- docker_merge_build_boiler_plate: &docker_merge_build_boiler_plate
+    name: merge_build_boiler_plate
+
+    concurrent: true
+
+    parameters:
+      - lf-infra-parameters:
+            project: '{project}'
+            branch: '{stream}'
+            stream: '{stream}'
+            lftools-version: '{lftools-version}'
+
+      - string:
+            name: ONOS_TAG
+            default: ''
+            description: 'Tag of ONOS to build'
+
+    scm:
+        - onf-infra-gerrit-scm:
+              git-url: '{git-url}'
+              refspec: '$GERRIT_REFSPEC'
+              branch: '$GERRIT_BRANCH'
+              submodule-disable: '{submodule-disable}'
+              submodule-recursive: '{submodule-recursive}'
+              submodule-timeout: '{submodule-timeout}'
+              choosing-strategy: gerrit
+              jenkins-ssh-credential: '{jenkins-ssh-credential}'
+              basedir: "$WORKSPACE"
+
+    triggers:
+        - gerrit:
+           server-name: 'ONOS Project Gerrit'
+           trigger-on:
+             - change-merged-event
+           projects:
+             - project-compare-type: PLAIN
+               project-pattern: '{project}'
+               branches:
+                 - branch-compare-type: ANT
+                   branch-pattern: '**/{stream}'
+               #file-paths: '{obj:gerrit_trigger_file_paths}'
+
 - job-template:
     #default name is global
     name: '{project-name}-{stream}-verify'
@@ -538,7 +580,45 @@
 
     <<: *job_boiler_plate
     # yamllint disable-line rule:key-duplicates
-    <<: *docker_build_boiler_plate
+    <<: *docker_release_build_boiler_plate
+
+    builders:
+      - lf-provide-maven-settings:
+          settings-file: 'release-build-maven-settings'
+          global-settings-file: 'release-build-maven-settings'
+      - config-file-provider:
+          files:
+            - file-id: 'onos-build-credentials'
+              target: 'onos-build-credentials'
+              variable: 'CREDENTIALS_FILE'
+            - file-id: 'buck-config-local'
+              target: '.buckconfig.local'
+              variable: 'BUCK_CONFIG_FILE'
+            - file-id: 'gpg-key'
+              target: 'jenkins.key'
+              variable: 'GPG_KEY_FILE'
+            - file-id: 'release-build-maven-settings'
+              target: 'settings.xml'
+              variable: 'MAVEN_SETTINGS'
+            - file-id: 'api-onosproject-ssh-key'
+              target: 'id_rsa.pub'
+              variable: 'API_ONOSPROJECT_SSH_KEY'
+
+    #put shell scripts in file then make sure shell check is installed on verify vms
+      - shell: !include-raw-escape: onos-docker-build.sh
+      # JJB 1.6.2 does not support parameter expansion on filename?
+      #- shell: !include-raw-escape: {project-name}-verify.sh
+
+- job-template:
+    #default name is global
+    name: 'onos-{stream}-docker-merge-build'
+
+    # Job template for Docker jobs
+    #
+
+    <<: *job_boiler_plate
+    # yamllint disable-line rule:key-duplicates
+    <<: *docker_merge_build_boiler_plate
 
     builders:
       - lf-provide-maven-settings:
@@ -779,6 +859,38 @@
       - 'onos-docker-build'
 
 - project:
+      name: onos-docker-merge-master-build
+      project-name: onos-docker-merge-master-build
+      project: onos
+
+      build-timeout: '240'
+      build-node: 'ubuntu16.04-basebuild-8c-15g'
+
+      stream:
+          - 'master'
+
+      jobs:
+          - 'onos-{stream}-docker-merge-build':
+                - ONOS_TAG: 'latest'
+                - disabled: true
+
+- project:
+      name: onos-docker-merge-released-build
+      project-name: onos-docker-merge-released-build
+      project: onos
+
+      build-timeout: '240'
+      build-node: 'ubuntu16.04-basebuild-8c-15g'
+
+      stream:
+          - 'onos-2.6'
+          - 'onos-2.5'
+
+      jobs:
+          - 'onos-{stream}-docker-merge-build':
+                - ONOS_TAG: '{stream}-latest'
+                - disabled: true
+- project:
       name: onos-snapshot
       project-name: onos-snapshot
       project: onos