构建状态REST API在“说明”字段中抛出400

时间:2019-05-15 08:39:47

标签: bitbucket bitbucket-api

Atlassian Bitbucket v5.11.1

我指的是official documentation

我正在管道中使用Jenkins httpRequest plugin。请注意,REST API接受的“描述”字段是我接受作为参数的字符串。

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']

如果'displayMessage'是例如

  

“内部版本16于20190218-1422完成”

  

“异常服务器返回HTTP响应代码:415,URL:https://lx649

,构建状态会适当更新,但是如果“ displayMessage”是这样的:

  

'TDE_component_Current_Release»TDE_DAP_REST_Payment_Payment»   项目/集成#17已完成,状态为FAILURE(传播:   如果忽略则为false)。

响应为400:

Response Code: HTTP/1.1 400 
Success code from [100‥599]

我的直接反应是对显示消息使用URLEncoder,但是在这种情况下,在浏览器上,构建状态消息看起来很丑,就像:

  

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

0 个答案:

没有答案