diff --git a/gradle.properties b/gradle.properties index 97584a8..ee7c6ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -version=5.11.1 +version=5.11.2 description=EPAM Report Portal. Cloud Jira plugin pluginId = JIRA Cloud diff --git a/src/main/java/com/epam/reportportal/extension/jira/command/GetIssueFieldsCommand.java b/src/main/java/com/epam/reportportal/extension/jira/command/GetIssueFieldsCommand.java index 88f147e..926ac45 100644 --- a/src/main/java/com/epam/reportportal/extension/jira/command/GetIssueFieldsCommand.java +++ b/src/main/java/com/epam/reportportal/extension/jira/command/GetIssueFieldsCommand.java @@ -94,6 +94,7 @@ protected List invokeCommand(Integration integration, Map allowed = new ArrayList<>(); // Provide values for custom fields with predefined options @@ -134,6 +135,7 @@ protected List invokeCommand(Integration integration, Map invokeCommand(Integration integration, Map { private final DataStoreService dataStoreService; + private static final String LINKED_ISSUE_TYPE = "Relates"; + public PostTicketCommand(ProjectRepository projectRepository, RequestEntityConverter requestEntityConverter, CloudJiraClientProvider cloudJiraClientProvider, JIRATicketDescriptionService descriptionService, DataStoreService dataStoreService) { @@ -86,6 +91,7 @@ protected Ticket invokeCommand(Integration integration, Map para // ticket type and/or components in JIRA. PostFormField issueType = new PostFormField(); PostFormField components = new PostFormField(); + PostFormField linkedIssue = null; for (PostFormField object : fields) { if ("issuetype".equalsIgnoreCase(object.getId())) { issueType = object; @@ -93,6 +99,9 @@ protected Ticket invokeCommand(Integration integration, Map para if ("components".equalsIgnoreCase(object.getId())) { components = object; } + if ("issuelinks".equalsIgnoreCase(object.getId())) { + linkedIssue = object; + } } expect(issueType.getValue().size(), equalTo(1)).verify(UNABLE_INTERACT_WITH_INTEGRATION, @@ -153,6 +162,9 @@ protected Ticket invokeCommand(Integration integration, Map para if (counter != 0) { client.getIssueClient().addAttachments(issue.getAttachmentsUri(), Arrays.copyOf(attachmentInputs, counter)).claim(); } + if (linkedIssue != null) { + linkIssues(client, issue, linkedIssue); + } return getTicket(createdIssue.getKey(), integration.getParams(), client).orElse(null); } catch (ReportPortalException e) { @@ -209,4 +221,15 @@ private Optional getTicket(String id, IntegrationParams details, JiraRes private SearchResult findIssue(String id, JiraRestClient jiraRestClient) { return jiraRestClient.getSearchClient().searchJql("issue = " + id).claim(); } + + private void linkIssues(JiraRestClient jiraRestClient, Issue issue, PostFormField field) { + String value = CollectionUtils.isNotEmpty(field.getValue()) ? field.getValue().get(0) : ""; + if (StringUtils.isNotEmpty(value)) { + String[] s = value.split(" "); + for (String v : s) { + LinkIssuesInput linkIssuesInput = new LinkIssuesInput(issue.getKey(), v, LINKED_ISSUE_TYPE); + jiraRestClient.getIssueClient().linkIssue(linkIssuesInput).claim(); + } + } + } } diff --git a/src/main/java/com/epam/reportportal/extension/jira/command/utils/JIRATicketUtils.java b/src/main/java/com/epam/reportportal/extension/jira/command/utils/JIRATicketUtils.java index 4bc849b..0a81483 100755 --- a/src/main/java/com/epam/reportportal/extension/jira/command/utils/JIRATicketUtils.java +++ b/src/main/java/com/epam/reportportal/extension/jira/command/utils/JIRATicketUtils.java @@ -137,6 +137,9 @@ public static IssueInput toIssueInput(JiraRestClient client, Project jiraProject issueInputBuilder.setFixVersionsNames(one.getValue()); continue; } + if (one.getId().equalsIgnoreCase(IssueFieldId.LINKS_FIELD.id)) { + continue; + } // Arrays and fields with 'allowedValues' handler if (null != cimFieldInfo.getAllowedValues()) {