【发布时间】:2014-06-24 11:38:11
【问题描述】:
有没有办法让我获得史诗的问题?
api 会返回很多关于 issue 的信息,但是没有包含史诗。
我正在使用 JIRA REST API (https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs)。
【问题讨论】:
有没有办法让我获得史诗的问题?
api 会返回很多关于 issue 的信息,但是没有包含史诗。
我正在使用 JIRA REST API (https://developer.atlassian.com/display/JIRADEV/JIRA+REST+APIs)。
【问题讨论】:
我想提取issue 的史诗名称,这让我困扰了几天。
关键是要意识到epic只是一个父问题,史诗名称是父issue 的summary 字段。
所以:
第一步
使用editmeta 查询查找存储史诗的自定义字段:
https://[your-jira-hostname]/jira/rest/api/2/issue/[issue-number]/editmeta
这将产生类似下面的内容,显示我们需要的自定义字段 ID
{
"fields": {
<SNIP>
"customfield_12360": {
"required": false,
"schema": {
"type": "any",
"custom": "com.pyxis.greenhopper.jira:gh-epic-link",
"customId": 12360
},
"name": "Epic Link",
"operations": [
"set"
]
}
<SNIP>
}
}
第 2 步
查询您的问题,提取自定义字段值
https://[your-jira-hostname]/jira/rest/api/2/issue/[issue-number]?fields=customfield_12360,summary
如果我们的问题是JIRA-34 说,这将产生类似
{
"expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"id": "39080",
"key": "JIRA-34",
"fields": {
"summary": "Write heavily upvoted answers for stack overflow",
"customfield_12360": "JIRA-33"
}
}
第 3 步
现在我们知道我们的史诗的问题编号是JIRA-33,所以现在查询史诗...
https://[your-jira-hostname]/jira/rest/api/2/issue/JIRA-33?fields=summary
{
"expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
"id": "39080",
"key": "JIRA-33",
"fields": {
"summary": "Improve StackOverflow reptuation"
}
}
JIRA-34 的史诗名称是“提高 StackOverflow 信誉”
完成。
【讨论】:
/rest/api/3/field/search?type=custom&query=Epic%20Link。例如,如果您需要从对问题搜索 API 的调用中提取史诗链接,这将非常有用。 API 文档在这里:developer.atlassian.com/cloud/jira/platform/rest/v3/…
要获取问题的史诗密钥:
发送请求到:/issue/ISSUE-NUMBER
并查看响应正文:
{
...,
fields: {
...,
customfield_11300: ... <- here, the epic should be listed. The number can be different
}
}
【讨论】:
customfield_10101。所以这不是检索史诗链接的可靠方法。
@fiat 有非常明确的步骤来查找自定义字段和史诗映射。在我的场景中,整个 jira 实例使用与史诗相同的自定义字段。所以我不需要重复这些步骤来映射每个项目。 希望这会有所帮助。
【讨论】:
根据https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-fields/,可以对/rest/api/3/field进行API调用,就可以得到这样的数据:
[
{
"id": "customfield_10014",
"key": "customfield_10014",
"name": "Epic Link",
"untranslatedName": "Epic Link",
"custom": true,
"orderable": true,
"navigable": true,
"searchable": true,
"clauseNames": [
"cf[10014]",
"Epic Link"
],
"schema": {
"type": "any",
"custom": "com.pyxis.greenhopper.jira:gh-epic-link",
"customId": 10014
}
},
]
然后回头看看你的问题json数据:
issue:
fields:
....
customfield_10014: OT-5
....
OT-5 是 Epic 的钥匙。
【讨论】: