From b791bb2d63e830820739d2f357d7ec0c8edec47e Mon Sep 17 00:00:00 2001 From: APiankouski <109206864+APiankouski@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:15:41 +0300 Subject: [PATCH 1/3] EPMRPP-92666 || Impossible to Post issue with "Linked Issues" field (#57) (cherry picked from commit 70c78b25d6ce617b98665052acfc2427170c2b62) --- .../jira/command/PostTicketCommand.java | 23 +++++++++++++++++++ .../jira/command/utils/JIRATicketUtils.java | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/com/epam/reportportal/extension/jira/command/PostTicketCommand.java b/src/main/java/com/epam/reportportal/extension/jira/command/PostTicketCommand.java index 4eae69b..9816a05 100644 --- a/src/main/java/com/epam/reportportal/extension/jira/command/PostTicketCommand.java +++ b/src/main/java/com/epam/reportportal/extension/jira/command/PostTicketCommand.java @@ -20,6 +20,7 @@ import com.atlassian.jira.rest.client.api.domain.*; import com.atlassian.jira.rest.client.api.domain.input.AttachmentInput; import com.atlassian.jira.rest.client.api.domain.input.IssueInput; +import com.atlassian.jira.rest.client.api.domain.input.LinkIssuesInput; import com.epam.reportportal.extension.ProjectMemberCommand; import com.epam.reportportal.extension.jira.command.utils.CloudJiraClientProvider; import com.epam.reportportal.extension.jira.command.utils.CloudJiraProperties; @@ -43,6 +44,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.StreamSupport; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import static com.epam.reportportal.extension.util.CommandParamUtils.ENTITY_PARAM; import static com.epam.ta.reportportal.commons.Predicates.*; @@ -64,6 +67,8 @@ public class PostTicketCommand extends ProjectMemberCommand { 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()) { From b5e40794ce7e685f6f9f457d6ed2912f486fa072 Mon Sep 17 00:00:00 2001 From: APiankouski <109206864+APiankouski@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:20:51 +0300 Subject: [PATCH 2/3] EPMRPP-93097 || JIRA Cloud. Integration is created without Issue Type (#59) (cherry picked from commit 6971cd4148c3196e1406f4777f9dc5ce3aac2e3f) --- .../extension/jira/command/GetIssueFieldsCommand.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 Date: Mon, 29 Jul 2024 10:07:17 +0300 Subject: [PATCH 3/3] Update plugin version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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