#!/bin/bash
+sudo apt-get install bc
#############################################################################################################################
################################################ F U N C T I O N S ##########################################################
#############################################################################################################################
}
latestBuild=$(getLatestBuild)
+latestBuildToRecord=""
consoleText=""
lastRecordedBuild=""
-timestampOfLastRecordedBuild=""
+latestRecordedBuild=""
+timestampOfLatestRecordedBuild=""
# Create and add header to the file
createAndAddHeader() {
# Get and calculate data for plot
if matched_line=$(echo "$consoleText" | grep -o -P "$patternToMatch"); then
echo "Matched line: $matched_line"
- limit_value=$(echo "$matched_line" | grep -o -P 'limit\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
+ limit_value=$(echo "$matched_line" | grep -o -P 'limit\s*\K\d+(\.\d+)?' | tr -cd '[:digit:].')
echo $limit_value
- took_value=$(echo "$matched_line" | grep -o -P 'took\s*\K\d+(,\d+)?' | tr -cd '[:digit:]')
+ took_value=$(echo "$matched_line" | grep -o -P 'took\s*\K\d+(\.\d+)?' | tr -cd '[:digit:].')
echo $took_value
- percentage=$(($took_value * 100 / $limit_value))
+ percentage=$(echo "scale=2; $took_value * 100.00 / $limit_value" | bc)
+
echo "Limit value: $limit_value"
echo "Took value: $took_value"
newLine="$buildNumber,$new_data"
if [ -z "$new_data" ]; then
echo "No new data"
+ lastRecordedBuild=$(echo "$lastLine" | awk -F, '{print $1}')
+ recordLatestRecordedBuild "$lastRecordedBuild"
elif [ $newLine == $lastLine ]; then
- echo "Data already exists"
+ echo "Data already exists"
+ recordLatestRecordedBuild "$buildNumber"
else
echo "$buildNumber,$new_data" >> $dataFile
echo "New data added"
+ recordLatestRecordedBuild "$buildNumber"
fi
- lastRecordedBuild=$buildNumber
- 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: $formattedTimestampOfLastBuild"
+}
+
+recordLatestRecordedBuild() {
+ latestBuildToRecord="$1"
+ timestampOfLatestRecordedBuild=$(curl -s "${JENKINS_JOB_URL}/${latestBuildToRecord}/api/json" | jq -r '.timestamp')
+ formattedTimestampOfLatestRecordedBuild=$(date -d "@$((timestampOfLatestRecordedBuild / 1000))" "+%B %e, %Y at %H:%M")
+ echo "Latest recorded build: $latestBuildToRecord"
+ echo "Date of latest recorded build: $formattedTimestampOfLatestRecordedBuild"
+ latestRecordedBuild=$latestBuildToRecord
}
buildStaticReport() {
</head>
<body>
<h1 style="text-align: center;">$reportTitle</h1>
- <h4>Last updated for performance job build no. $lastRecordedBuild on $formattedTimestampOfLastBuild</h4>
+ <h4>Last updated for performance job build no. $latestRecordedBuild on $formattedTimestampOfLatestRecordedBuild</h4>
+ <p>The performance tests job runs daily at 02:15 UTC, providing performance metrics. The following graphs update at 04:15 UTC.</p>
+ <p>Successful performance tests job build adds new data, but even if a build fails, existing data is retained.</p>
+ <p>Updates occur whenever new successful data is available.</p>
+
<table align="center">
<tr> <!-- First Row -->
<td align="center">
</head>
<body>
<h1>$reportTitle</h1>
- <h4>Last updated for performance job build no. $lastRecordedBuild on $formattedTimestampOfLastBuild</h4>
+ <h4>Last updated for performance job build no. $latestRecordedBuild on $formattedTimestampOfLatestRecordedBuild</h4>
<img src="$chartFileName" alt="Graph Image">
</body>
</html>