Improve jjb for pti rtp project

Refactor merge job to offload the image building process
to a new release job which will be triggered once or twice
per release. This helps save resources of ci infrastructure

Issue-ID: INF-15
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Change-Id: I23ed988e06451622d9f144e5f4a1380c3eff86ee
diff --git a/jjb/oran-jjb/oran-shell-jobs.yaml b/jjb/oran-jjb/oran-shell-jobs.yaml
index 56d966d..f4a236c 100644
--- a/jjb/oran-jjb/oran-shell-jobs.yaml
+++ b/jjb/oran-jjb/oran-shell-jobs.yaml
@@ -177,3 +177,50 @@
                 - branch-compare-type: ANT
                   branch-pattern: '**/{branch}'
               file-paths: '{obj:gerrit_trigger_file_paths}'
+
+# Build and publish artifact from gerrit by shell script.
+# Triggered automatically by merging specific release file;
+# can be run on any branch.
+#
+# Required parameters:
+#   build-node:     label (flavor) of jenkins build minion
+#   project:        git repository
+#   project-name:   Jenkins job name prefix
+#   script:         shell script to execute
+# Optional parameters:
+#   branch:         git branch pattern, defaults to master
+#   stream:         friendly stream name (often same as branch), defaults to master
+#   gerrit_release_file_paths: Pathname pattern of the release file to trigger this job
+- job-template:
+    name: '{project-name}-shell-release-{stream}'
+    id: oran-shell-release
+    <<: *oran_shell_common
+
+    gerrit_release_file_paths:
+      - compare-type: REG_EXP
+        pattern: 'releases\/oran-shell-release.*\.yaml'
+
+    scm:
+      - lf-infra-gerrit-scm:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: '{submodule-recursive}'
+          submodule-timeout: '{submodule-timeout}'
+          submodule-disable: '{submodule-disable}'
+          choosing-strategy: default
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on:
+            - change-merged-event
+          projects:
+            - project-compare-type: ANT
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: '**/{branch}'
+              file-paths: '{obj:gerrit_release_file_paths}'
+
diff --git a/jjb/pti-rtp/pti-rtp.yaml b/jjb/pti-rtp/pti-rtp.yaml
index f4ed03e..e19d2dd 100644
--- a/jjb/pti-rtp/pti-rtp.yaml
+++ b/jjb/pti-rtp/pti-rtp.yaml
@@ -41,6 +41,17 @@
 - project:
     <<: *pti_rtp_common
     name: pti-rtp-merge
+    # runs about 40 minutes
+    build-timeout: 60
+    script: !include-raw-escape:
+        - install-yocto-prereq-centos.sh
+        - verify-yocto.sh
+    jobs:
+      - oran-shell-merge
+
+- project:
+    <<: *pti_rtp_common
+    name: pti-rtp-release-merge
     # demand 200GB storage
     build-node: centos7-docker-2c-8g-200g
     # runs about 18 hours
@@ -50,4 +61,4 @@
         - build-yocto.sh
         - upload-yocto.sh
     jobs:
-      - oran-shell-merge
+      - oran-shell-release