问题
It's really hard to find a clear answer about how to create a comment on an issue which is internal only.
回答1:
The JIRA Cloud REST API Documentation specifies the following schema for setting properties on comments when creating or updating a comment on an incident
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
}
}
To make a comment on an issue internal (meaning only service desk agents can see the comment) you need to set the sd.public.comment
key to have the value { "internal": true }
Which can be achieved by passing the following JSON in the body of the create or update API request.
{
"properties": {
"key": "sd.public.comment",
"value": {
"internal": true
}
}
}
You will also need to set the Content-Type header on the request.
Content-Type: application/json
The following is an example of a creating an internal comment using a Groovy script - the scripting language used by ScriptRunner (a popular JIRA plugin)
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()
Note that Object / JSON mapping will differ depending on which scripting language or HTTP Request framework you are using.
来源:https://stackoverflow.com/questions/45031475/how-to-create-an-internal-comment-on-a-jira-issue-using-the-jira-cloud-rest-api