Change the trigger of plot job to a timer

     - remove the trigger from post build
     - add the timer as a trigger build
     - modify the charts for timestamp

Issue-ID: CPS-1753
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Change-Id: I6013bc0c3497b18b4570b55c49887e7d2e3c9042
diff --git a/jjb/onap/cps/cps-performance-test-jobs.yaml b/jjb/onap/cps/cps-performance-test-jobs.yaml
index 2bb5245..ecbdd3c 100644
--- a/jjb/onap/cps/cps-performance-test-jobs.yaml
+++ b/jjb/onap/cps/cps-performance-test-jobs.yaml
@@ -35,14 +35,11 @@
     jobs:
       - 'onap-{project-name}-{stream}-performance-test-java'
 
-    publishers:
-        - trigger:
-              project: 'onap-cps-performance-tests-plots'
-
 - project:
     name: cps-tests-plots
     project: cps
     project-name: cps
+    timer: "15 4 * * *"
 
     jobs:
         - 'onap-{project-name}-performance-tests-plots'
\ No newline at end of file
diff --git a/jjb/onap/cps/prepare-performance-tests-data.sh b/jjb/onap/cps/prepare-performance-tests-data.sh
index cfc3a9e..1b4b61f 100644
--- a/jjb/onap/cps/prepare-performance-tests-data.sh
+++ b/jjb/onap/cps/prepare-performance-tests-data.sh
@@ -20,8 +20,8 @@
 update_datanodes_pattern="^.*Update 100 data nodes.*"
 batch_delete_pattern="^.*Batch delete 100 whole lists.*"
 
-all_patterns=("$creating_bookstore_pattern" "$read_datatreees_pattern" "$update_datanodes_pattern" "$batch_delete_pattern")
 new_data=""
+JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
 
 # Get latest build
 getLatestBuild() {
@@ -32,8 +32,7 @@
 latestBuild=$(getLatestBuild)
 consoleText=""
 lastRecordedBuild=""
-dateOfLastRecordedBuild=""
-JENKINS_JOB_URL="https://jenkins.nordix.org/job/onap-cps-master-performance-test-java"
+timestampOfLastRecordedBuild=""
 
 # Create and add header to the file
 createAndAddHeader() {
@@ -48,6 +47,7 @@
     fi
 }
 
+# Get the console text from specific build of the performance job
 getConsoleText() {
     buildToRead=$1
     consoleURL="${JENKINS_JOB_URL}/${buildToRead}/consoleText"
@@ -100,9 +100,10 @@
         echo "New data added"
     fi
     lastRecordedBuild=$buildNumber
-    dateOfLastRecordedBuild=$(curl -s "${JENKINS_JOB_URL}/${lastRecordedBuild}/api/json" | jq -r '.timestamp' | xargs -I {} date -d "@{}")
+    timestampOfLastRecordedBuild=$(curl -s "${JENKINS_JOB_URL}/${lastRecordedBuild}/api/json" | jq -r '.timestamp')
+	formattedTimestampOfLastBuild=$(date -d "@$((timestampOfLastRecordedBuild / 1000))" "+%B %e, %Y at %H:%M")
     echo "last Recorded build: $lastRecordedBuild"
-    echo "date of last recorded build: $dateOfLastRecordedBuild"
+    echo "date of last recorded build: $formattedTimestampOfLastBuild"
 }
 
 buildStaticReport() {
@@ -142,8 +143,8 @@
 
 buildHTMLReport() {
 
-    chartTitle1="$1"
-    chartFileName1="$2"   # Get the chart file name as the first parameter
+    chartTitle1="$1" # i.e Get the chart file name as the first parameter
+    chartFileName1="$2"
 
     chartTitle2="$3"
     chartFileName2="$4"
@@ -154,7 +155,7 @@
     chartTitle4="$7"
     chartFileName4="$8"
 
-    reportTitle="$9"     # Get the report title as the second parameter
+    reportTitle="$9"     # i.e Get the report title as the ninth parameter
 
 cat <<EOT > "index.html"
 <!DOCTYPE html>
@@ -164,8 +165,7 @@
 </head>
 <body>
     <h1 style="text-align: center;">$reportTitle</h1>
-    <h4>Last recorded build number:			$lastRecordedBuild</h4>
-   	<h4>Date of the last recoded build:		$dateOfLastRecordedBuild</h4>
+    <h4>Last updated for performance job build no. $lastRecordedBuild on $formattedTimestampOfLastBuild</h4>
     <table align="center">
         <tr> <!-- First Row -->
             <td align="center">
@@ -205,8 +205,7 @@
     </head>
     <body>
         <h1>$reportTitle</h1>
-        <h4>Last recorded build number:			$lastRecordedBuild</h4>
-   	    <h4>Date of the last recoded build:		$dateOfLastRecordedBuild</h4>
+        <h4>Last updated for performance job build no. $lastRecordedBuild on $formattedTimestampOfLastBuild</h4>
         <img src="$chartFileName" alt="Graph Image">
     </body>
     </html>
@@ -247,7 +246,7 @@
 getLatestBuild
 if [ -z "$(ls -A)" ]; then
     	# Calculate the starting value for the loop
-        startValue=$((latestBuild - 70))
+        startValue=$((latestBuild - 100))
 
         # Start the loop from startValue up to latestBuild
         for ((i=startValue; i<=latestBuild; i++)); do
diff --git a/jjb/onap/global-templates-onap-java.yaml b/jjb/onap/global-templates-onap-java.yaml
index bede667..5bc3b85 100644
--- a/jjb/onap/global-templates-onap-java.yaml
+++ b/jjb/onap/global-templates-onap-java.yaml
@@ -239,10 +239,6 @@
       - shell:
           !include-raw-escape: ./verify-jobs.sh
 
-    publishers:
-      - trigger:
-          project: 'onap-cps-performance-tests-plots'
-
 # csits for diferent projects are different so need to have special handling
 - job-template:
     name: 'onap-policy-docker-{stream}-csit-java'