Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 5.11.2 #61

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=5.11.1
version=5.11.2
description=EPAM Report Portal. Cloud Jira plugin
pluginId = JIRA Cloud
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
// Field ID for next JIRA POST ticket requests
String fieldID = issueField.getId();
String fieldType = issueField.getSchema().getType();
boolean isRequired = issueField.isRequired();
List<AllowedValue> allowed = new ArrayList<>();

// Provide values for custom fields with predefined options
Expand Down Expand Up @@ -134,6 +135,7 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
}
}
if (fieldID.equalsIgnoreCase(IssueFieldId.ISSUE_TYPE_FIELD.id)) {
isRequired = true;
defValue = Collections.singletonList(issueTypeParam);
}
if (fieldID.equalsIgnoreCase(IssueFieldId.ASSIGNEE_FIELD.id)) {
Expand All @@ -154,7 +156,7 @@ protected List<PostFormField> invokeCommand(Integration integration, Map<String,
continue;
}

result.add(new PostFormField(fieldID, fieldName, fieldType, issueField.isRequired(), defValue, allowed));
result.add(new PostFormField(fieldID, fieldName, fieldType, isRequired, defValue, allowed));
}
return result;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;
Expand All @@ -64,6 +67,8 @@ public class PostTicketCommand extends ProjectMemberCommand<Ticket> {

private final DataStoreService dataStoreService;

private static final String LINKED_ISSUE_TYPE = "Relates";

public PostTicketCommand(ProjectRepository projectRepository, RequestEntityConverter requestEntityConverter,
CloudJiraClientProvider cloudJiraClientProvider, JIRATicketDescriptionService descriptionService,
DataStoreService dataStoreService) {
Expand All @@ -86,13 +91,17 @@ protected Ticket invokeCommand(Integration integration, Map<String, Object> 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;
}
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,
Expand Down Expand Up @@ -153,6 +162,9 @@ protected Ticket invokeCommand(Integration integration, Map<String, Object> 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) {
Expand Down Expand Up @@ -209,4 +221,15 @@ private Optional<Ticket> 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();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Loading