From b47a09f1a4f013296721e8833afa3630758ac2f0 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 14 Jan 2022 12:46:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BAjira=E7=BC=BA=E9=99=B7?= =?UTF-8?q?sprint=E5=8F=82=E6=95=B0=E6=8A=A5=E9=94=99=20--bug=3D1009214=20?= =?UTF-8?q?--user=3D=E9=99=88=E5=BB=BA=E6=98=9F=20=E3=80=90github#8748?= =?UTF-8?q?=E3=80=91=E5=85=B3=E8=81=94JIRA=20Software=20Cloud=E5=89=8D?= =?UTF-8?q?=E6=8F=90=E4=B8=8B=EF=BC=8C=E5=88=9B=E5=BB=BAJIRA=20Bug?= =?UTF-8?q?=E6=97=B6customfield=E5=AF=B9=E5=BA=94=E7=9A=84value=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF=20https://www.tap?= =?UTF-8?q?d.cn/55049933/s/1091709?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/track/issue/JiraPlatform.java | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index 55dc207eae..5609b6aa58 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -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 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; }