Improve error handling and stability for Jenkins Plugin #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We had some users occasionally encountering error conditions like JSON parsing issues where the previous approach was discarding useful debugging information about what the original response body was. The stack trace would reveal a parsing error but not the original text that was attempted to be parsed.
Similarly we were getting the odd failure of the plugin when builds weren't ready when we tried to perform actions.
Solution
We have reworked the response to return a string and the JSON is being parsed as a separate step so that if a parse error is encountered we can include the original body in the error message. This required a bit of restructuring the methods as with this approach we had no way of creating an
HttpResponse<JsonNode>
object, so now the bits of error handling that required the response have been pulled into the originalgetProject
method and we return JsonNodes for consumption by higher level methods.We also added a method at the start of the run to wait up to 10 seconds for a completed build to avoid any timing issues. This appears to be reasonable common amongst similar plugins.