Last active
December 13, 2020 20:07
-
-
Save PramodKumarYadav/4c7576f4f7a11c8227c8c6a9b0d867f1 to your computer and use it in GitHub Desktop.
mvn result parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://devops.stackexchange.com/questions/6085/how-can-we-get-the-jenkins-console-output-in-a-text-file | |
# https://unix.stackexchange.com/questions/264962/print-lines-of-a-file-between-two-matching-patterns | |
# https://issues.jenkins.io/browse/JENKINS-61263 | |
echo "Getting test results log from: $1" | |
cd ci | |
curl -q $1 > run-log.txt | |
echo "Get text between Result and maven-surefire report-plugin sysout" | |
pattern1="Results:" | |
pattern2="maven-surefire-report-plugin:" | |
sed -n "/$pattern1/,/$pattern2/p" ./run-log.txt | |
echo "Get final Test run counts " | |
raw_result=$( sed -n "/$pattern1/,/$pattern2/p" ./run-log.txt | grep 'Tests run:' ) | |
echo "Remove text [INFO]/[WARNING]/[ERROR] and keep the part after ']' and save to a file" | |
trimmed_result=${raw_result##*]} | |
echo $trimmed_result > ./result-log.txt | |
cat ./result-log.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment