Hi,
I am using Jenkins and have integrated JMeter for testing. JMeter is generating a file with results properly using shell script. I have to validate the results and exit the shell with non-zero so my jenkins job gets failed. I tried multiple ways to grep the output file and read the results in an array but its not working.
I gave a grep command, but got to remove '(' and ')' as shell is not accepting so this is not converting to array
Error :
array=($(grep -oP '(?<=error>)[^<]+' "TestCases/results.jtl") )
accepted by shell:
array=$(grep -oP '(?<=error>)[^<]+' "TestCases/results.jtl")
Below is the file , using shell script I have to exit when 'error' count with value true is greater than 1.
results.jtl File :
<testResults version="1.2">
<httpSample t="73" it="0" lt="0" ct="65" ts="1486696391218" s="false" lb="LoopbackRequest" rc="Non HTTP response code: org.apache.http.NoHttpResponseException" rm="Non HTTP response message: 192.168.99.100:2011 failed to respond" tn="DPIntegration_Testing 1-1" dt="text" by="2249" sby="0" ng="1" na="1">
<assertionResult>
<name>XPath Assertion</name>
<failure>false</failure>
<error>true</error>
<failureMessage>SAXException: Content is not allowed in prolog.</failureMessage>
</assertionResult>
</httpSample>
<httpSample t="70" it="0" lt="0" ct="63" ts="1486696392639" s="false" lb="LoopbackRequest" rc="Non HTTP response code: org.apache.http.NoHttpResponseException" rm="Non HTTP response message: 192.168.99.100:2011 failed to respond" tn="DPIntegration_Testing 1-1" dt="text" by="2249" sby="0" ng="1" na="1">
<assertionResult>
<name>XPath Assertion</name>
<failure>false</failure>
<error>true</error>
<failureMessage>SAXException: Content is not allowed in prolog.</failureMessage>
</assertionResult>
</httpSample>
</testResults>
Can someone please help me with this ?
Thanks.