What is jira-client?
The jira-client npm package is a Node.js wrapper for the JIRA REST API. It allows developers to interact with JIRA programmatically, enabling them to automate tasks, retrieve data, and manage JIRA issues, projects, and other resources.
What are jira-client's main functionalities?
Create Issue
This feature allows you to create a new issue in JIRA. The code sample demonstrates how to configure the jira-client and create a new issue with specified fields such as project key, summary, description, and issue type.
const JiraClient = require('jira-client');
const jira = new JiraClient({
protocol: 'https',
host: 'your-jira-host.atlassian.net',
username: 'your-username',
password: 'your-password',
apiVersion: '2',
strictSSL: true
});
jira.addNewIssue({
fields: {
project: { key: 'TEST' },
summary: 'New issue from jira-client',
description: 'Creating an issue via jira-client',
issuetype: { name: 'Task' }
}
}).then(issue => {
console.log(`Created issue: ${issue.key}`);
}).catch(err => {
console.error(err);
});
Get Issue
This feature allows you to retrieve details of a specific issue by its key. The code sample shows how to configure the jira-client and fetch an issue using its key.
const JiraClient = require('jira-client');
const jira = new JiraClient({
protocol: 'https',
host: 'your-jira-host.atlassian.net',
username: 'your-username',
password: 'your-password',
apiVersion: '2',
strictSSL: true
});
jira.findIssue('TEST-1').then(issue => {
console.log(`Found issue: ${issue.key}`);
console.log(issue);
}).catch(err => {
console.error(err);
});
Update Issue
This feature allows you to update an existing issue in JIRA. The code sample demonstrates how to configure the jira-client and update the summary and description of an issue using its key.
const JiraClient = require('jira-client');
const jira = new JiraClient({
protocol: 'https',
host: 'your-jira-host.atlassian.net',
username: 'your-username',
password: 'your-password',
apiVersion: '2',
strictSSL: true
});
jira.updateIssue('TEST-1', {
fields: {
summary: 'Updated summary',
description: 'Updated description'
}
}).then(issue => {
console.log(`Updated issue: ${issue.key}`);
}).catch(err => {
console.error(err);
});
Search Issues
This feature allows you to search for issues in JIRA using JQL (JIRA Query Language). The code sample shows how to configure the jira-client and perform a search for issues in a specific project with a specific status.
const JiraClient = require('jira-client');
const jira = new JiraClient({
protocol: 'https',
host: 'your-jira-host.atlassian.net',
username: 'your-username',
password: 'your-password',
apiVersion: '2',
strictSSL: true
});
jira.searchJira('project = TEST AND status = "To Do"').then(result => {
console.log('Search results:', result.issues);
}).catch(err => {
console.error(err);
});
Other packages similar to jira-client
jira-connector
The jira-connector package is another Node.js wrapper for the JIRA REST API. It provides similar functionalities to jira-client, such as creating, updating, and searching for issues. However, jira-connector offers a more modular approach, allowing developers to include only the parts of the API they need.
atlassian-jira
The atlassian-jira package is a comprehensive library for interacting with JIRA's REST API. It supports a wide range of JIRA functionalities, including issue management, project management, and user management. Compared to jira-client, atlassian-jira offers more extensive documentation and examples, making it easier for developers to get started.