Atlassian Bitbucket v5.11.1
I am referring to the official documentation.
I am using the Jenkins httpRequest plugin within a pipeline. Note that the 'description' field accepted by the REST API is a string that I accept as an argument.
def jsonBody = """
    {
        "state": "${buildState}",
        "key": "${displayName}",
        "name": "${displayName}",
        "url": "${buildURL}",
        "description": "${displayMessage}"
    }
    """
 def parametersForHttpRequest = [url: 'https://git.net/rest/build-status/1.0/commits/' + gitCommit,
                                        ignoreSslErrors: true,
                                        acceptType: 'APPLICATION_JSON',
                                        authentication: 'stash-api-credentials',
                                        httpMode: 'POST',
                                        contentType: 'APPLICATION_JSON',
                                        requestBody: jsonBody,
                                        validResponseCodes: '100:599']If the 'displayMessage' is e.g:
'Build 16 completed at 20190218-1422'
or
'Exception Server returned HTTP response code: 415 for URL: https://lx649'
, the build status is updated appropriately but if the 'displayMessage' is something like this:
'TDE_component_Current_Release » TDE_DAP_REST_Payment_Payment » project/integration #17 completed with status FAILURE (propagate: false to ignore)'
the response is 400:
Response Code: HTTP/1.1 400 
Success code from [100‥599]My immediate reaction was to use URLEncoder for the displayMessage but in that case, on the browser, the build status message looks ugly, like:
Exception+TDE_component_Current_Release+%C2%BB+TDE_DAP_REST_Payment_Payment+%C2%BB+project%2Fintegration+%2327+completed+with+status+FAILURE+%28propagate%3A+false+to+ignore%29+in+build+12