Read Jira Comments
Updated: Jan 31, 2023
This example shows you how to read comments for a Jira issue using DataPipeline.
Java Code Listing
package com.northconcepts.datapipeline.examples.jira; import com.northconcepts.datapipeline.core.Record; import com.northconcepts.datapipeline.jira.client.JiraService; public class ReadJiraComments { private static final String JIRA_DOMAIN = "JIRA_DOMAIN"; private static final String JIRA_USERNAME = "USERNAME"; private static final String JIRA_API_KEY = "API_KEY"; private static final String JIRA_ISSUE_ID = "ISSUE_ID"; public static void main(String... args) { JiraService service = new JiraService(JIRA_DOMAIN, JIRA_USERNAME, JIRA_API_KEY); Record record = service.getIssueComments(JIRA_ISSUE_ID); System.out.println(record); } }
Code Walkthrough
JIRA_DOMAIN
is your Jira domain e.ghttps://company.atlassian.net
.JIRA_USERNAME
is your Jira username.JIRA_API_KEY
is your Jira token which you can easily create in https://id.atlassian.com/manage/api-tokens.- Create JiraService using above properties.
- For given
JIRA_ISSUE_ID
, comments will be read. - JiraService.getIssueComments(String issueId) method is used to fetch all the comments for a given issue id. This method returns a record with all the comments with details.
- Print this record containing all the comments.
Sample Console Output
Record (MODIFIED) (has child records) { 0:[10000]:RECORD=[ Record (MODIFIED) (is child record) { 0:[author]:STRING=[Jane Doe]:String 1:[body]:STRING=[What is the progress on this?]:String 2:[created]:STRING=[2022-06-24T08:56:28.515+0000]:String 3:[updated]:STRING=[2022-06-24T08:56:28.515+0000]:String }]:Record 1:[10001]:RECORD=[ Record (MODIFIED) (is child record) { 0:[author]:STRING=[John Doe]:String 1:[body]:STRING=[This is currently in progress.]:String 2:[created]:STRING=[2022-06-24T08:56:38.684+0000]:String 3:[updated]:STRING=[2022-06-24T08:56:38.684+0000]:String }]:Record 191:[10191]:RECORD=[ Record (MODIFIED) (is child record) { 0:[author]:STRING=[Jane Doe]:String 1:[body]:STRING=[Let's discuss this in our next meeting]:String 2:[created]:STRING=[2023-01-29T18:06:27.455+0000]:String 3:[updated]:STRING=[2023-01-29T18:06:27.455+0000]:String }]:Record }