Read Jira issues

Updated: Jan 6, 2023

This example shows you how to read Jira issues using DataPipeline.

For this example you need to be familiar with JQL which stands for Jira Query Language and is used to search for issues in Jira.

Java Code Listing

package com.northconcepts.datapipeline.examples.jira;

import com.northconcepts.datapipeline.core.StreamWriter;
import com.northconcepts.datapipeline.jira.JiraIssueReader;
import com.northconcepts.datapipeline.jira.JiraSearch;
import com.northconcepts.datapipeline.job.Job;

public class ReadJiraIssues {

    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 JQL = "YOUR_JIRA_QUERY";

    public static void main(String... args) {
        JiraSearch jiraSearch = new JiraSearch()
            .setJql(JQL)
            .setMaxResults(5);

        JiraIssueReader reader = new JiraIssueReader(JIRA_DOMAIN, JIRA_USERNAME, JIRA_API_KEY, jiraSearch);
        Job.run(reader, new StreamWriter(System.out));
    }
}

Code Walkthrough

  1. JIRA_DOMAIN is your Jira domain e.g https://company.atlassian.net.
  2. JIRA_USERNAME is your Jira username.
  3. JIRA_API_KEY is your Jira token which you can easily create in https://id.atlassian.com/manage/api-tokens.
  4. JQL as stated above is the query that you will use when fetching the results e.g. status IN ("To Do", "In Progress", "Closed") will output issues with the status "To Do", "In Progress" or "Closed".
  5. JiraSearch object is created and the query is set i.e. .setJql(JQL), the maximum results that should be fetched is also set i.e. .setMaxResults(5), the default maximum result is 50.
  6. JiraIssueReader is used to read the Jira issues.
  7. Job.run() is then used to transfer data from the reader to StreamWriter which will print the output to the console.
Mobile Analytics