fix: 创建jira缺陷sprint参数报错

--bug=1009214 --user=陈建星 【github#8748】关联JIRA Software Cloud前提下,创建JIRA Bug时customfield对应的value数据类型错误 https://www.tapd.cn/55049933/s/1091709
This commit is contained in:
chenjianxing 2022-01-14 12:46:33 +08:00 committed by 刘瑞斌
parent 2330f82931
commit 436a1a50c1

View File

@ -148,7 +148,6 @@ public class JiraPlatform extends AbstractIssuePlatform {
JiraConfig jiraConfig = setUserConfig();
JSONObject addJiraIssueParam = buildUpdateParam(issuesRequest, jiraConfig.getIssuetype());
JiraAddIssueResponse result = jiraClientV2.addIssue(JSONObject.toJSONString(addJiraIssueParam));
JiraIssue issues = jiraClientV2.getIssues(result.getId());
@ -171,6 +170,38 @@ public class JiraPlatform extends AbstractIssuePlatform {
return res;
}
/**
* sprint 传参数比较特殊需要要传数值
* @param fields
*/
private void setSprintParam(JSONObject fields) {
String sprintKey = null;
String projectKey = getProjectId(this.projectId);
JiraConfig config = getConfig();
Map<String, JiraCreateMetadataResponse.Field> createMetadata = new HashMap<>();
try {
createMetadata = jiraClientV2.getCreateMetadata(projectKey, config.getIssuetype());
} catch (Exception e) {}
for (String name : createMetadata.keySet()) {
JiraCreateMetadataResponse.Field item = createMetadata.get(name);
JiraCreateMetadataResponse.Schema schema = item.getSchema();
if (schema != null && schema.getCustom() != null && schema.getCustom().endsWith("sprint")) {
sprintKey = item.getKey();
break;
}
}
if (StringUtils.isNotBlank(sprintKey)) {
JSONObject field = fields.getJSONObject(sprintKey);
if (field != null) {
try {
fields.put(sprintKey, field.getInteger("id"));
} catch (Exception e) {}
}
}
}
private JSONObject buildUpdateParam(IssuesUpdateRequest issuesRequest, String issuetypeStr) {
issuesRequest.setPlatform(key);
@ -201,6 +232,7 @@ public class JiraPlatform extends AbstractIssuePlatform {
fields.put("description", desc);
parseCustomFiled(issuesRequest, fields);
}
setSprintParam(fields);
return addJiraIssueParam;
}