Forum Discussion

jkrier's avatar
jkrier
Regular Contributor
9 years ago

Adding raw response to Jenkins Test Results

I have a project that runs by Jenkins every night. In the 'Test Results' page in Jenkins it displays the assertions that fail but I would like to also capture the response. I have done this in other projects using testRunner.fail but in this project I want it to keep running even if there is a failed assertion. I tried adding a Script Assertion to check the HTTP response but I am not able to get the response as part of the error.

 

def actualResponse = messageExchange.response
def headers = actualResponse.responseHeaders
def httpStatus = headers['#status#']
def xmlResponse = messageExchange.responseContentAsXml
if (xmlResponse != null){
	assert httpStatus == "HTTP/1.1 200 OK" : xmlResponse
	log.info xmlResponse
	log.error(xmlResponse)
}

I tried 3 different ways to capture the response but none of these are accomplishing my goal.

 

Does anyone have any experience doing this kind of thing using Jenkins or any ideas on how to add the response to the assertion message?

1 Reply

  • jkrier's avatar
    jkrier
    Regular Contributor

    Not sure why this happened but I reloaded my project and now I am seeing the response logged to the Jenkins Test Results page.

     

    This matter can be considered resolved. The line in the code I provided "assert httpStatus == "HTTP/1.1 200 OK" : xmlResponse" is working.