我试图用jira问题和自定义字段来做这件事,事实证明这很困难。
为了简明扼要,我可以说以下是我收到的内容:
"expand": "editmeta,renderedFields,transitions,changelog,operations",
"id": "59378",
"self": "https://myjirainstance.com/jira/rest/api/2/issue/59378",
"key": "AB-12345",
"fields":
{
"type": "Bug",
"typeid": "19",
"status": "Backlog",
"summary": "I'm a big bad bug",
"closedDate": null,
"customfield_10170":[{"self":"http://address/1938","value":"Critical","id":"10404"}]
},
我之前已经映射了所有其他字段,如此
curl to jira | jq '.["issues"] |
map({
key: .key,
type: .fields.issuetype.name,
typeid: .fields.issuetype.id,
status: .fields.status.name,
summary: .fields.summary,
closedDate: .fields.resolutiondate,
flag: .fields.customfield_10170["value"]})'
> output/json/FullIssueList.json
但添加最后一行以使value
为suggested here会导致整个对象从输出文件中排除。
任何想法?
答案 0 :(得分:1)
我找到了答案,
原始和不正确的尝试如下所示:
curl to jira | jq '.["issues"] |
map({
key: .key,
type: .fields.issuetype.name,
typeid: .fields.issuetype.id,
status: .fields.status.name,
summary: .fields.summary,
closedDate: .fields.resolutiondate,
flag: .fields.customfield_10170["value"]})'
> output/json/FullIssueList.json
我没有将flag
的条目视为单独的数组。所以单行应该是:
flag: .fields.customfield_10170[0].value
这将获取数组中的第一个元素[0]
,然后请求value
字段。