【发布时间】:2017-12-15 08:02:10
【问题描述】:
很难找到关于如何对仅限内部的问题发表评论的明确答案。
【问题讨论】:
标签: json groovy jira jira-rest-api
很难找到关于如何对仅限内部的问题发表评论的明确答案。
【问题讨论】:
标签: json groovy jira jira-rest-api
JIRA Cloud REST API 文档指定了以下架构,用于在创建或更新事件评论时在 cmets 上设置属性
https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/comment-addComment
"properties": {
"type": "array",
"items": {
"title": "Entity Property",
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {}
},
"additionalProperties": false
}
}
要对内部问题发表评论(意味着只有服务台代理可以看到评论),您需要将 sd.public.comment 键设置为具有值 { "internal": true }
这可以通过在创建或更新 API 请求的正文中传递以下 JSON 来实现。
{
"properties": {
"key": "sd.public.comment",
"value": {
"internal": true
}
}
}
您还需要在请求中设置 Content-Type 标头。
Content-Type: application/json
以下是使用 Groovy 脚本(ScriptRunner(一种流行的 JIRA 插件)使用的脚本语言)创建内部注释的示例
post("/rest/api/2/issue/${issue.id}/comment")
.header("Content-Type", "application/json")
.body([
body: "This is the text which will appear in the comment",
properties: [
[key: "sd.public.comment", value: [ "internal": true ]]
]
]).asString()
请注意,对象/JSON 映射会因您使用的脚本语言或 HTTP 请求框架而异。
【讨论】: