通过电子邮件向 JIRA 中的 Issue 添加评论
Add comment to Issue in JIRA via email
我创建了一个 MVC 应用程序,该应用程序向 JIRA 发送了一封电子邮件,而 JIRA 又成功地创建了问题。但是在应用程序中,我想通过能够向现有问题添加评论来更新问题。因为此时如果您发送另一封电子邮件,它只会创建另一个问题,并且在当前问题上添加评论是不可行的。
有没有一种方法可以为 JIRA 设置电子邮件处理程序,以便当它收到电子邮件时可以识别问题(通过使用问题密钥),然后添加评论。
我很确定您可以添加评论,只需将其设为文本正文并将 JIRA 设置为将其解释为评论而非描述即可。但是,如果您将 Issue Key 作为电子邮件的主题,是否有办法设置 JIRA 以便它更新该问题?
Jira 有一个 REST API - 那你为什么不发送 REST 请求来添加评论?
POST /rest/api/2/issue/{issueIdOrKey}/comment?expand
Adds a new comment to an issue.
request query parameters
parameter value description
expand string optional flags: renderedBody (provides body rendered in HTML)
acceptable request representations: application/json
Example
{
"body": "Lorem ipsum dolor sit amet....",
"visibility": {
"type": "role",
"value": "Administrators"
}
}
available response representations:
201
Example
{
"self": "http://www.example.com/jira/rest/api/2/issue/10010/comment/10000",
"id": "10000",
"author": {
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
"name": "fred",
"displayName": "Fred F. User",
"active": false
},
"body": "Lorem ipsum dolor sit amet...",
"updateAuthor": {
"self": "http://www.example.com/jira/rest/api/2/user?username=fred",
"name": "fred",
"displayName": "Fred F. User",
"active": false
},
"created": "2015-06-23T08:28:32.838+0000",
"updated": "2015-06-23T08:28:32.838+0000",
"visibility": {
"type": "role",
"value": "Administrators"
}
}
Returned if add was successful
400
Returned if the input is invalid (e.g. missing required fields, invalid values, and so forth).
我发现我可以通过执行以下操作通过电子邮件向现有问题添加评论。
首先在 MVC 应用程序中,我将通过从其 ID 中获取它来识别问题,然后我将从中检索问题密钥。
Dim Issue As New IssueResultTable
Issue.key
然后我将以这种格式将其作为我电子邮件的主题:
主题:[JIRA} (KEY-00000)
如果 JIRA 系统中存在该键,它将自动搜索它并将主体作为评论添加到现有问题。
如果一封电子邮件在其主题行中包含一个现有问题键,并且在您的 JIRA 系统中包含该问题键,则电子邮件处理程序会将电子邮件内容添加为对该问题的评论。
然后您还可以选中删除引号选项以从评论中删除以前的电子邮件内容。
我创建了一个 MVC 应用程序,该应用程序向 JIRA 发送了一封电子邮件,而 JIRA 又成功地创建了问题。但是在应用程序中,我想通过能够向现有问题添加评论来更新问题。因为此时如果您发送另一封电子邮件,它只会创建另一个问题,并且在当前问题上添加评论是不可行的。
有没有一种方法可以为 JIRA 设置电子邮件处理程序,以便当它收到电子邮件时可以识别问题(通过使用问题密钥),然后添加评论。
我很确定您可以添加评论,只需将其设为文本正文并将 JIRA 设置为将其解释为评论而非描述即可。但是,如果您将 Issue Key 作为电子邮件的主题,是否有办法设置 JIRA 以便它更新该问题?
Jira 有一个 REST API - 那你为什么不发送 REST 请求来添加评论?
POST /rest/api/2/issue/{issueIdOrKey}/comment?expand
Adds a new comment to an issue.
request query parameters
parameter value description
expand string optional flags: renderedBody (provides body rendered in HTML)
acceptable request representations: application/json
Example { "body": "Lorem ipsum dolor sit amet....", "visibility": { "type": "role", "value": "Administrators" } }
available response representations:
201 Example { "self": "http://www.example.com/jira/rest/api/2/issue/10010/comment/10000", "id": "10000", "author": { "self": "http://www.example.com/jira/rest/api/2/user?username=fred", "name": "fred", "displayName": "Fred F. User", "active": false }, "body": "Lorem ipsum dolor sit amet...", "updateAuthor": { "self": "http://www.example.com/jira/rest/api/2/user?username=fred", "name": "fred", "displayName": "Fred F. User", "active": false }, "created": "2015-06-23T08:28:32.838+0000", "updated": "2015-06-23T08:28:32.838+0000", "visibility": { "type": "role", "value": "Administrators" } } Returned if add was successful 400 Returned if the input is invalid (e.g. missing required fields, invalid values, and so forth).
我发现我可以通过执行以下操作通过电子邮件向现有问题添加评论。
首先在 MVC 应用程序中,我将通过从其 ID 中获取它来识别问题,然后我将从中检索问题密钥。
Dim Issue As New IssueResultTable
Issue.key
然后我将以这种格式将其作为我电子邮件的主题:
主题:[JIRA} (KEY-00000)
如果 JIRA 系统中存在该键,它将自动搜索它并将主体作为评论添加到现有问题。
如果一封电子邮件在其主题行中包含一个现有问题键,并且在您的 JIRA 系统中包含该问题键,则电子邮件处理程序会将电子邮件内容添加为对该问题的评论。
然后您还可以选中删除引号选项以从评论中删除以前的电子邮件内容。