IssueInputBuilder issueBuilder = new IssueInputBuilder("Project1", 5L);//5 is the id for subtask type. You can know the id of subtask type by querying this REST api /rest/api/2/issue/createmeta issueBuilder.setDescription(">> Test Description"); issueBuilder.setSummary("Test summary"); issueBuilder.setProjectKey("Project1"); Map<String, Object> parent = new HashMap<String, Object>(); parent.put("key", "SOMEISSUE-234"); FieldInput parentField = new FieldInput("parent", new ComplexIssueInputFieldValue(parent)); Map<String, Object> customField = new HashMap<String, Object>(); customField.put("value", "someValue");//This is some custom field value on the subtask customField.put("id", "12345");//This is the id of the custom field. You can know this by calling REST GET for a manually created sub-task issueBuilder.setFieldInput(parentField); issueBuilder.setFieldValue("customfield_12345", new ComplexIssueInputFieldValue(customField));//here again you have to query an existing subtask to know the "customfield_*" value com.atlassian.jira.rest.client.domain.input.IssueInput issueInput = issueBuilder.build(); BasicIssue bIssue = restClient.getIssueClient().createIssue(issueInput, pm); System.out.println(">>> " + bIssue.getKey());
public IssueInputBuilder setComponents(BasicComponent... basicComponents) { return setComponents(Lists.newArrayList(basicComponents)); }
public IssueInputBuilder(String projectKey, Long issueTypeId) { setProjectKey(projectKey); setIssueTypeId(issueTypeId); }
public IssueInputBuilder setComponentsNames(Iterable<String> names) { return setFieldInput(new FieldInput(IssueFieldId.COMPONENTS_FIELD, toListOfComplexIssueInputFieldValueWithSingleKey(names, "name"))); }
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; } }
if (ticket.getId() == null || ticket.getId().equals("")) { IssueInputBuilder builder = new IssueInputBuilder( config.getProjectKey(), config.getIssueTypeId()); builder.setReporterName(config.getUsername()); builder.setSummary(ticket.getSummary()); builder.setDescription(ticket.getDetails()); createdIssue = jira.getIssueClient().createIssue(builder.build()).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to create issue.", 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; }
/** * Puts new {@link FieldInput} with given id and value into fields collection. * <p> * <strong>Recommended</strong> way to set field value is to use {@link IssueInputBuilder#setFieldValue(String, Object)}. * * @param id Field's id * @param value Complex value for field * @return this */ @SuppressWarnings("unused") public IssueInputBuilder setFieldValue(String id, ComplexIssueInputFieldValue value) { return setFieldInput(new FieldInput(id, value)); }
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); } }
IssueInput issueToFluentUpdate(Issue issue, com.atlassian.jira.rest.client.api.domain.Issue jiraIssue, Project project) throws NotFoundException { checkUnsupportedUpdateFields(issue); IssueInputBuilder inputBuilder = new IssueInputBuilder(jiraIssue.getProject().getKey(), jiraIssue.getIssueType().getId()); issue.getSummary().ifPresent(inputBuilder::setSummary); inputBuilder.setFieldInput(new FieldInput(IssueFieldId.COMPONENTS_FIELD, issue.getComponents().stream().map(e -> ComplexIssueInputFieldValue.with("name", e)).collect(Collectors.toList())) ); issue.getDescription().ifPresent(inputBuilder::setDescription); issue.getAssignee().ifPresent(assignee -> inputBuilder.setFieldInput( new FieldInput(IssueFieldId.ASSIGNEE_FIELD, ComplexIssueInputFieldValue.with("name", assignee.getName().orElseThrow(this::nullUsername))))); // this is ok but does nothing if there is no permissions. issue.getStage().getStateMap().entrySet() .stream().filter(entry -> entry.getValue() != FlagStatus.NO_SET) .forEach(entry -> inputBuilder.setFieldInput(new FieldInput(JSON_CUSTOM_FIELD + FLAG_MAP.get(entry.getKey()), entry.getValue().getSymbol()))); Map<String, Version> versionsMap = StreamSupport.stream(project.getVersions().spliterator(), false) .collect(Collectors.toMap(Version::getName, Function.identity())); updateFixVersions(issue, versionsMap, inputBuilder); updateStreamStatus(issue, jiraIssue, versionsMap, inputBuilder); return inputBuilder.build(); }
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); } }
@SuppressWarnings("unused") public IssueInputBuilder(BasicProject project, IssueType issueType, String summary) { this(project, issueType); setSummary(summary); }
public IssueInputBuilder setPriority(BasicPriority priority) { return setPriorityId(priority.getId()); }
public IssueInputBuilder setProject(BasicProject project) { return setProjectKey(project.getKey()); }
public IssueInputBuilder setComponents(Iterable<BasicComponent> basicComponents) { return setComponentsNames(EntityHelper.toNamesList(basicComponents)); }
public IssueInputBuilder setAssignee(BasicUser assignee) { return setAssigneeName(assignee.getName()); }
if (ticket.getId() == null || ticket.getId().equals("")) { IssueInputBuilder builder = new IssueInputBuilder( config.getProjectKey(), config.getIssueTypeId()); builder.setReporterName(config.getUsername()); builder.setSummary(ticket.getSummary()); builder.setDescription(ticket.getDetails()); createdIssue = jira.getIssueClient().createIssue(builder.build()).get(); } catch (InterruptedException | ExecutionException e) { throw new PluginException("Failed to create issue.", e);
public IssueInputBuilder setDescription(String summary) { return setFieldInput(new FieldInput(IssueFieldId.DESCRIPTION_FIELD, summary)); }
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); } }
public IssueInputBuilder setComponentsNames(Iterable<String> names) { return setFieldInput(new FieldInput(IssueFieldId.COMPONENTS_FIELD, toListOfComplexIssueInputFieldValueWithSingleKey(names, "name"))); }