Add project-specific CSIT job template

 - add template for project-specific CSIT
 - apply the template in music component (note that this requires
   https://gerrit.onap.org/r/c/music/distributed-kv-store/+/114637
   to be merged to find the proper plans)
 - pass selected infra parameters to triggered docker build and
   CSIT jobs to have them use appropriate branch

Issue-ID: INT-1760
Signed-off-by: Lasse Kaihlavirta <l.kaihlavirt@partner.samsung.com>
Change-Id: Id83e54548243e9d5dc7d932acae469a8b295c48f
diff --git a/jjb/integration/integration-macros.yaml b/jjb/integration/integration-macros.yaml
index d485b8e..b472846 100644
--- a/jjb/integration/integration-macros.yaml
+++ b/jjb/integration/integration-macros.yaml
@@ -68,6 +68,11 @@
       - shell: "${WORKSPACE}/run-csit.sh ${TESTPLAN} ${TESTOPTIONS}"
 
 - builder:
+    name: integration-run-project-test
+    builders:
+      - shell: "${WORKSPACE}/csit/run-project-csit.sh ${TESTPLAN} ${TESTOPTIONS}"
+
+- builder:
     name: integration-autorelease-fix-relativepaths
     builders:
       - shell: "${WORKSPACE}/autorelease/scripts/fix-relativepaths.sh"
@@ -132,6 +137,16 @@
           only-critical: false
 
 - publisher:
+    name: integration-project-robot
+    publishers:
+      - robot:
+          output-path: 'csit/archives'
+          other-files: ''
+          unstable-threshold: '{unstable-if}'
+          pass-threshold: '{pass-if}'
+          only-critical: false
+
+- publisher:
     name: integration-docker-compose-logs
     publishers:
       - postbuildscript:
diff --git a/jjb/integration/integration-templates-csit.yaml b/jjb/integration/integration-templates-csit.yaml
index c978753..3ae98a2 100644
--- a/jjb/integration/integration-templates-csit.yaml
+++ b/jjb/integration/integration-templates-csit.yaml
@@ -130,6 +130,63 @@
           send-to-individuals: true
 
 - job-template:
+    name: '{project-name}-{stream}-project-csit-{functionality}'
+    disabled: '{disabled}'
+
+    project-type: freestyle
+    build-node: 'ubuntu1804-docker-8c-8g'
+    node: '{build-node}'
+    recipients: ''
+    java-version: 'openjdk11'
+    python-version: python3
+
+    properties:
+      - lf-infra-properties:
+          project: '{project}'
+          build-days-to-keep: '{build-days-to-keep}'
+
+    parameters:
+      - infra-parameters:
+          project: '{project}'
+          branch: '{branch}'
+          refspec: 'refs/heads/{branch}'
+          artifacts: '{archive-artifacts}'
+      - integration-test-plan:
+          test-plan: 'plans/{functionality}'
+      - integration-test-options:
+          test-options: '{robot-options}'
+
+    scm:
+      - gerrit-trigger-scm:
+          refspec: '$GERRIT_REFSPEC'
+          choosing-strategy: 'gerrit'
+          submodule-recursive: '{submodule-recursive}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    builders:
+      - lf-infra-pre-build
+      - lf-update-java-alternatives:
+          java-version: '{java-version}'
+      - integration-install-robotframework
+      - inject:
+          properties-file: 'env.properties'
+      - integration-run-project-test
+
+    publishers:
+      - integration-project-robot:
+          unstable-if: 0.0
+          pass-if: 100.0
+      - lf-infra-publish
+      - email:
+          recipients: '{recipients}'
+          notify-every-unstable-build: false
+          send-to-individuals: true
+
+- job-template:
     name: '{project-name}-unified-review-{stream}-test'
     disabled: '{disabled}'
     project-type: freestyle
@@ -169,12 +226,18 @@
             condition: UNSTABLE_OR_BETTER
             predefined-parameters: |
               UNIQUE_DOCKER_TAG=$BUILD_TAG
+              PROJECT=$PROJECT
+              BRANCH=$BRANCH
+              GERRIT_REFSPEC=$GERRIT_REFSPEC
             block: true
       - trigger-builds:
-         -  project: "{project-name}-{stream}-csit-{review-functionality}"
+         -  project: '{project-name}-{stream}-project-csit-{review-functionality}'
             condition: UNSTABLE_OR_BETTER
             predefined-parameters: |
               UNIQUE_DOCKER_TAG=$BUILD_TAG
+              PROJECT=$PROJECT
+              BRANCH=$BRANCH
+              GERRIT_REFSPEC=$GERRIT_REFSPEC
             block: true
     triggers:
       - gerrit-trigger-patch-submitted: