We have a REST web service to which we POST an xml input script, and it returns an xml result document.
Currently we are performing this step manually using Postman, but would like to add a stage to our build configuration that makes the same REST call. Based on some simple xpathing of the result document we can decide whether to continue to teh next (deploy) stage.
I’m not sure if this is supported by Continua, or if there is a work around using some type of scripting. The call will contain the http method, the URL (including params), some headers etc. And how the access the response including the body and potentially http headers.
Have a look at the HTTP Request build event handler. This can be used to send a request to your web service on a specific event during the build, such as when a stage completes. It can then set a variable based on the response. This variable can then be tested in a stage skip or promote condition, or as part of the stage workflow.
I’ve set up a basic web service to return a small xml snippet
“<?xml version="1.0" ?>”
The server returns a Content-Type header of “application/xml;charset=utf-8”
I’ve created an event which can call this web service and tries to extract the @value attribute to store in a config variable. The error is
Error selecting value for variable ‘AutoTestResult’ using XPath ‘/response/result/@value’. Message: The XPath expression evaluated to unexpected type System.Xml.Linq.XAttribute.
Response did not match the requested format [Xml].
The response content was: <?xml version="1.0" ?><response><result value="ok"/></response>
Thanks for reporting this. The current implementation only allows for selection of elements by XPath - not attributes. We’ll update it allow all possible node types today and send you a new version when ready.
The quick turn around is much appreciated That got me out of a tight spot - thanks.
My use case is that we have a web service API (product A) that we develop and support.
I have got Continua to build and run the unit tests to build when code is checked in - and then only proceed to build and deploy the web service if the unit tests pass. Very nice .
My next stage in the CI plan is to call another web service (automated test server) which is loaded with xml test scripts that are called against the product A web service’s API. This returns a structured xml document that I can XPath into to check how our product A performed against the automated tests.
This is where I will use the Continua event, so my next task will be to extract, using XPath, the tests that fail.
Can I then display these in the Continua UI, a bit like how the unit test results are displayed. Would I need to write / configure some type of translator ?
You can log the variable values to a build comment using the Log Entry action. This will be displayed on the Details tab of the Build view.
Currently, the only way to add custom results to the Unit Tests tab, is to construct a file in XUnit, NUnit, MSTest or JUnit format and use the relevant Unit Test Import action to load the results into Continua CI.
There are no Continua CI actions which can be used to create this file - but you could pass the variables to FinalBuilder, PowerShell, Cake or another external program.