bobcarroll / jira-client

A simple JIRA REST client for Java
Other
475 stars 380 forks source link

How to automate customize field in jira #259

Open dpruthi opened 5 years ago

dpruthi commented 5 years ago

Hi Dear,

Can you please guide me how this api helps me to automate custom jira field.

Automate: 'Yes'/'No'

I have a custom field in my jira ticket name 'Automate' having 'yes/no' option.

hari1985 commented 4 years ago

@dpruthi - Here is the detailed implementation. Hope this helps.

private static String getCustomField(String fieldName, Issue issue) { Map customFieldMap = (Map) issue.getField(fieldName); return customFieldMap.get("value").toString(); }

Enum: BRAND("customfield_15516") -> You can get the field name by visiting the REST Jira API which will give you the custom field values where you can punch those in the above Enum.

Jira REST API: https://jira.yourdomain.com/rest/api/latest/issue/issue-key

I have the POJO where I'm setting the required fields for update in Jira. jiraIssuePojo.setDpTeam(getDpTeamValue(getCustomField(CustomField.DPTEAM.getJiraCustomField(), dpTeam))); try { jiraReportImpl.updateFateIssue(jiraIssuePojo); LOGGER.info("FATE Updated with Components/Fabric URL for {} ", jiraIssuePojo.getIssueKey()); } catch (JiraException e) { e.printStackTrace(); } Btw you have to build the 0.6-SNAPSHOT jar from jira-client in-order to update the Custom Fields.

0.5 version won't support for CustomFields.