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
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.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".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.- JiraIssueReader is used to read the Jira issues.
- Job.run() is then used to transfer data from the
reader
to StreamWriter which will print the output to the console.