public Issue getIssue(String issueKey) { try { return jiraRestClient.getIssueClient().getIssue(issueKey).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get issue error. cause: " + e.getMessage(), e); return null; } }
public List<Transition> getAvailableActions(String issueKey) { final Issue issue = getIssue(issueKey); try { final Iterable<Transition> transitions = jiraRestClient.getIssueClient() .getTransitions(issue) .get(timeout, TimeUnit.SECONDS); return Lists.newArrayList(transitions); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client get available actions error. cause: " + e.getMessage(), e); return Collections.emptyList(); } }
public Issue progressWorkflowAction(String issueKey, Integer actionId) { final TransitionInput transitionInput = new TransitionInput(actionId); final Issue issue = getIssue(issueKey); try { jiraRestClient.getIssueClient().transition(issue, transitionInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client process workflow action error. cause: " + e.getMessage(), e); } return issue; }
createdIssue = jira.getIssueClient().createIssue(builder.build()).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to create issue.", e); issue = jira.getIssueClient().getIssue(ticket.getId()).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to get issue with id:" + ticket.getId(), e); transitions = jira.getIssueClient().getTransitions(issue).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to get transitions for issue with id:" + issue.getId(), e); jira.getIssueClient().transition(issue, new TransitionInput(transition.getId(), comment)).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to get resolve issue with id:" + issue.getId(), e); jira.getIssueClient().transition(issue, new TransitionInput(transition.getId(), comment)).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to reopen issue with id:" + issue.getId(), e);
issueClient.updateIssue(jiraIssue.getKey(), update).claim(); if (!JiraFields.hasSameIssueStatus(issue, jiraIssue)) { String transition = getJiraTransition(issue, jiraIssue); for(Transition t : issueClient.getTransitions(jiraIssue).get()) { if(t.getName().equals(transition)) { issueClient.transition(jiraIssue, new TransitionInput(t.getId())).claim(); issueClient.linkIssue(linkIssuesInput).claim();
public BasicIssue createIssue(String projectKey, String description, String assignee, Iterable<String> components, String summary, @Nonnull Long issueTypeId, @Nullable Long priorityId) { IssueInputBuilder builder = new IssueInputBuilder(); builder.setProjectKey(projectKey) .setDescription(description) .setIssueTypeId(issueTypeId) .setSummary(summary); if (priorityId != null) { builder.setPriorityId(priorityId); } if (!assignee.equals("")) builder.setAssigneeName(assignee); if (Iterators.size(components.iterator()) > 0){ builder.setComponentsNames(components); } final IssueInput issueInput = builder.build(); try { return jiraRestClient.getIssueClient().createIssue(issueInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "JIRA REST createIssue error: " + e.getMessage(), e); return null; } }
public void updateIssue(String issueKey, List<Version> fixVersions) { final IssueInput issueInput = new IssueInputBuilder().setFixVersions(fixVersions) .build(); try { jiraRestClient.getIssueClient().updateIssue(issueKey, issueInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client update issue error. cause: " + e.getMessage(), e); } }
public void addComment(String issueId, String commentBody, String groupVisibility, String roleVisibility) { final URIBuilder builder = new URIBuilder(uri) .setPath(String.format("%s/issue/%s/comment", baseApiPath, issueId)); final Comment comment; if (StringUtils.isNotBlank(groupVisibility)) { comment = Comment.createWithGroupLevel(commentBody, groupVisibility); } else if (StringUtils.isNotBlank(roleVisibility)) { comment = Comment.createWithRoleLevel(commentBody, roleVisibility); } else { comment = Comment.valueOf(commentBody); } try { jiraRestClient.getIssueClient().addComment(builder.build(), comment).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client add comment error. cause: " + e.getMessage(), e); } }
/** * Does the same as {@link #getIssueMetaData(JiraRestClient, String, String, String)} but filters by issueTypeId instead of issueTypeName. * * @see #getIssueMetaData(JiraRestClient, String, String, String) */ public static List<CimProject> getIssueMetaData(JiraRestClient client, String expandos, Long issueTypeId, String projectKey) throws ExecutionException, InterruptedException { return Lists.newArrayList(client.getIssueClient().getCreateIssueMetadata( new GetCreateIssueMetadataOptions( expandos == null ? null : Lists.newArrayList(expandos), null, // no issue type names issueTypeId == null ? null : Lists.newArrayList(issueTypeId), projectKey == null ? null : Lists.newArrayList(projectKey), null)) // no project ids .get()); }
createdIssue = jira.getIssueClient().createIssue(builder.build()).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to create issue.", e); issue = jira.getIssueClient().getIssue(ticket.getId()).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to get issue with id:" + ticket.getId(), e); transitions = jira.getIssueClient().getTransitions(issue).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to get transitions for issue with id:" + issue.getId(), e); jira.getIssueClient().transition(issue, new TransitionInput(transition.getId(), comment)).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to get resolve issue with id:" + issue.getId(), e); jira.getIssueClient().transition(issue, new TransitionInput(transition.getId(), comment)).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to reopen issue with id:" + issue.getId(), e);
JiraRestClient restClient; public boolean createIssue(IssueJiraDTO issueDTO) throws IOException{ final IssueInputBuilder builder = new IssueInputBuilder(PROJECT_KEY, issueDTO.getIssueType(), issueDTO.getSummary()); final ComponentRestClient componentClient = restClient.getComponentClient(); try { openClient(); //completamos los datos Component component = componentClient.getComponent(new URI(issueDTO.getComponent())).claim(); builder.setComponents(component); builder.setFieldValue(CODCESCEFIELDID, issueDTO.getCodcesce()); builder.setFieldValue(LINKCAFIELD, issueDTO.getLinkCA().trim()); builder.setFieldValue(SECURITYFIELD, ComplexIssueInputFieldValue.with("id", issueDTO.getSecurityLevel())); builder.setPriorityId(issueDTO.getPriority()); builder.setDescription(issueDTO.getDescription()); final IssueInput input = builder.build(); // create issue final IssueRestClient client = restClient.getIssueClient(); final BasicIssue issue = client.createIssue(input).claim(); logger.info("Incidencia creada correctamente: "+ issue.getId()); }catch(Exception e){ logger.error("Error al crear la Issue en Jira: " + issueDTO.getCodcesce(), e); } finally { closeClient(); } return true; }
public void setIssueLabels(String issueKey, List<String> labels) { final IssueInput issueInput = new IssueInputBuilder() .setFieldValue(IssueFieldId.LABELS_FIELD.id, labels) .build(); try { jiraRestClient.getIssueClient().updateIssue(issueKey, issueInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client update labels error for issue "+issueKey, e); } }
private void postComment(Issue issue, Comment comment) throws NotFoundException { if (comment.isPrivate()) Utils.logWarnMessage(LOG, "Private comments are not currently supported by " + getClass().getName()); com.atlassian.jira.rest.client.api.domain.Issue jiraIssue = getIssue(issue); com.atlassian.jira.rest.client.api.domain.Comment c = com.atlassian.jira.rest.client.api.domain.Comment.valueOf(comment.getBody()); restClient.getIssueClient().addComment(jiraIssue.getCommentsUri(), c).claim(); }
/** * Does the same as {@link #getIssueMetaData(JiraRestClient, String, String, String)} but filters by issueTypeId instead of issueTypeName. * * @see #getIssueMetaData(JiraRestClient, String, String, String) */ public static List<CimProject> getIssueMetaData(JiraRestClient client, String expandos, Long issueTypeId, String projectKey) throws ExecutionException, InterruptedException { return Lists.newArrayList(client.getIssueClient().getCreateIssueMetadata( new GetCreateIssueMetadataOptions( expandos == null ? null : Lists.newArrayList(expandos), null, // no issue type names issueTypeId == null ? null : Lists.newArrayList(issueTypeId), projectKey == null ? null : Lists.newArrayList(projectKey), null)) // no project ids .get()); }
private com.atlassian.jira.rest.client.api.domain.Issue getIssue(String trackerId) throws NotFoundException { try { return restClient.getIssueClient().getIssue(trackerId).get(); } catch (Exception e) { throw new NotFoundException(e); } }
public void setIssueFields(String issueKey, List<JiraIssueField> fields) { IssueInputBuilder builder = new IssueInputBuilder(); for (JiraIssueField field : fields) builder.setFieldValue(field.getId(), field.getValue()); final IssueInput issueInput = builder.build(); try { jiraRestClient.getIssueClient().updateIssue(issueKey, issueInput).get(timeout, TimeUnit.SECONDS); } catch (Exception e) { LOGGER.log(WARNING, "jira rest client update fields error for issue " + issueKey, e); } }
/** * Convenient method to get the meta data to create issues. * It allows queriing by issueTypeName and projectKey. * * @param client the {@link JiraRestClient} to make the ReST call. * @param expandos The expandos, to expand the json object if required * @param issueTypeName Filter by issue type name (e.g. Bug). May be null. * @param projectKey Filter by project key (e.g. DUM). May be null. * @return The issue meta data for the queried projects. * @throws ExecutionException * @throws InterruptedException */ public static List<CimProject> getIssueMetaData(JiraRestClient client, String expandos, String issueTypeName, String projectKey) throws ExecutionException, InterruptedException { return Lists.newArrayList(client.getIssueClient().getCreateIssueMetadata( new GetCreateIssueMetadataOptions( expandos == null ? null : Lists.newArrayList(expandos), issueTypeName == null ? null : Lists.newArrayList(issueTypeName), null, // no issue type ids projectKey == null ? null : Lists.newArrayList(projectKey), null)) // no project ids .get()); }
.getIssue(issue.getKey(), Arrays.asList(new Expandos[] { Expandos.CHANGELOG}))
/** * Convenient method to get the meta data to create issues. * It allows queriing by issueTypeName and projectKey. * * @param client the {@link JiraRestClient} to make the ReST call. * @param expandos The expandos, to expand the json object if required * @param issueTypeName Filter by issue type name (e.g. Bug). May be null. * @param projectKey Filter by project key (e.g. DUM). May be null. * @return The issue meta data for the queried projects. * @throws ExecutionException * @throws InterruptedException */ public static List<CimProject> getIssueMetaData(JiraRestClient client, String expandos, String issueTypeName, String projectKey) throws ExecutionException, InterruptedException { return Lists.newArrayList(client.getIssueClient().getCreateIssueMetadata( new GetCreateIssueMetadataOptions( expandos == null ? null : Lists.newArrayList(expandos), issueTypeName == null ? null : Lists.newArrayList(issueTypeName), null, // no issue type ids projectKey == null ? null : Lists.newArrayList(projectKey), null)) // no project ids .get()); }
private Ticket getInternal(String ticketId, JiraRestClient jira) throws PluginException { // w00t Issue issue; try { issue = jira.getIssueClient().getIssue(ticketId).get(); } catch (InterruptedException|ExecutionException e) { throw new PluginException("Failed to get issue with id: " + ticketId, e); } if (issue != null) { Ticket ticket = new Ticket(); ticket.setId(issue.getKey()); ticket.setModificationTimestamp(String.valueOf(issue.getUpdateDate().toDate().getTime())); ticket.setSummary(issue.getSummary()); ticket.setDetails(issue.getDescription()); ticket.setState(getStateFromStatusName(issue.getStatus().getName())); return ticket; } else { return null; } }