Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

GitHub: Jira REST API Node.js Script for Issue Migration

Hari Babu
Contributor
May 12, 2025

Migrate issues (including fields like summary, description, assignee, labels, etc.) from one Jira project to another using Node.js and the Jira REST API.

const client = require('./helpers/jiraClient');
const { jql, sourceProjectKey, destinationProjectKey } = require('./config');

async function fetchIssues() {
const res = await client.post('/search', {
jql,
maxResults: 50,
fields: ['summary', 'description', 'issuetype', 'assignee', 'labels'],
});
return res.data.issues;
}

async function createIssue(issue) {
const newIssue = {
fields: {
project: { key: destinationProjectKey },
summary: issue.fields.summary,
description: issue.fields.description,
issuetype: { id: issue.fields.issuetype.id },
labels: issue.fields.labels,
assignee: issue.fields.assignee ? { id: issue.fields.assignee.accountId } : null,
},
};

const res = await client.post('/issue', newIssue);
console.log(`Created issue: ${res.data.key}`);
return res.data.key;
}

(async () => {
try {
const issues = await fetchIssues();
for (const issue of issues) {
await createIssue(issue);
}
console.log("✅ Migration complete.");
} catch (err) {
console.error("❌ Error during migration:", err.response?.data || err.message);
}
})();

0 answers

Suggest an answer

Log in or Sign up to answer