I have a requirement that I acquire this code review report in JSON format from the Jenkins Job (performed via PowerShell). Then I save this json report has environment variable. Then, from within Jenkins, send an email with the attached json using the Groovy Postbuild action.
Now I need to read the json and search for **"ErrorSeverity": "Error" ** before making another request to open a JIRA ticket using the JIRA API.
Any ideas on how to read a json file to retrieve the ErrorSeverity, and then triggers the JIRA API if the ErrorSeverity is error?
Sample JSON output:
#json{ "FilePath": "E:\\packages\\workspace\\Dummy_Repo_PR-53\\Calculator\\Calculator_EnterInputData.xaml", "ErrorCode": "ST-NMG-004", "ErrorSeverity": "Warning", "Description": "Log Message display name is defined many times. Current allowed threshold is 1. Code contains 2.", "Recommendation": "Names of activities should give a clear indication of how they are being used. Default names are usually too generic. Please avoid duplicate names. [Learn more.]", "FilePath": "E:\\packages\\workspace\\Dummy_Repo_PR-53\\Calculator\\Calculator_EnterInputData.xaml", "ErrorCode": "ST-NMG-004", "ErrorSeverity": "Info", "Description": "Assign_CalculationType_ExactName display name is defined many times. Current allowed threshold is 1. Code contains 4.", "Recommendation": "Names of activities should give a clear indication of how they are being used. Default names are usually too generic. Please avoid duplicate names. [Learn more.]", "FilePath": "E:\\packages\\workspace\\Dummy_Repo_PR-53\\Calculator\\Calculator_EnterInputData.xaml", "ErrorCode": "CU-NMG-007", "ErrorSeverity": "Error", "Description": "Assign_CalculationType_ExactName display name is defined many times. Code contains 4", "Recommendation": "Activity should have a unique descriptive name [Learn more.]", "FilePath": "E:\\packages\\workspace\\Dummy_Repo_PR-53\\Calculator\\Calculator_EnterInputData.xaml", "ErrorCode": "CU-NMG-001", "ErrorSeverity": "Info", "Description": "ActivityName Attach Window_Calculator doesn't follow the standard guidelines", "Recommendation": "Rename the activity with the standard guidelines" }#json
Tried to grep "ErrorSeverity" : "Error" from json and so for I was not successful.