IssueInputBuilder issueBuilder = null; issueBuilder = new IssueInputBuilder(PRJCT_KEY,ISSUE_TYPE); issueBuilder.setFieldValue(epicLinkId, epicLinkvalue);
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());
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; }
final String attributeValue = eachEntry.getValue(); final Object mappedFieldValue = fieldMapFunctionCache.get(eachField.getSchema()).mapToFieldValue(eachField.getId(), eachField.getSchema(), attributeValue); builder.setFieldValue(eachField.getId(), mappedFieldValue); populatedFields.add(eachField.getId()); break; // we found a representation, now continue with next attribute
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); } }
final String attributeValue = eachEntry.getValue(); final Object mappedFieldValue = fieldMapFunctionCache.get(eachField.getSchema()).mapToFieldValue(eachField.getId(), eachField.getSchema(), attributeValue); builder.setFieldValue(eachField.getId(), mappedFieldValue); populatedFields.add(eachField.getId()); break; // we found a representation, now continue with next attribute
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); } }