This repository was archived by the owner on Jun 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjira-to-github.js
More file actions
96 lines (82 loc) · 2.34 KB
/
Copy pathjira-to-github.js
File metadata and controls
96 lines (82 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var JiraApi = require('jira').JiraApi;
var GitHubApi = require('github');
//var util = require('util');
// The GitHub API handles concurrent inserts really badly
// Guess they are using optimistic locking without retry, or something like that
// Serializing requests fixes the issue
var https = require('https');
https.globalAgent.maxSockets = 1;
var config = require('./config');
var jira = new JiraApi(config.jira.proto, config.jira.host, config.jira.port, config.jira.user, config.jira.password, '2');
var github = new GitHubApi({ version: "3.0.0" });
github.authenticate({
type: "basic",
username: config.github.user,
password: config.github.password
});
jira.searchJira(config.jira.jql,
{
maxResults: 9999,
fields: [ 'summary', 'description', 'priority', 'components', 'issuetype' ]
}, function(error, result) {
result.issues.forEach(function(issue) {
labels = [];
if([ 'Blocker', 'Critical' ].indexOf(issue.fields.priority.name) >= 0)
labels.push( 'prio:high' );
issue.fields.components.forEach(function(component) {
switch(component.name) {
case 'API':
labels.push( 'comp:api' );
break;
case 'Back end general':
labels.push( 'comp:backend' );
break;
case 'Build process':
labels.push( 'comp:build-process' );
break;
case 'Datasource: S+':
labels.push( 'comp:datasource-syllabus' );
break;
case 'Documentation':
labels.push( 'comp:documentation' );
break;
case 'Front end / GWT':
labels.push( 'comp:gwt' );
break;
case 'Help':
labels.push( 'comp:help' );
break;
case 'Mobile':
labels.push( 'comp:mobile' );
break;
}
});
switch(issue.fields.issuetype.name) {
case 'Bug':
labels.push( 'type:bug' );
break;
case 'Improvement':
labels.push( 'type:enhancement' );
break;
case 'New Feature':
labels.push( 'type:feature' );
break;
case 'Task':
labels.push( 'type:task' );
break;
}
github.issues.create({
user: config.github.repouser,
repo: config.github.reponame,
title: issue.fields.summary,
body: issue.fields.description,
labels: labels
} , function(err, res) {
if(err)
console.log("Error creating issue: " + issue.fields.summary);
else
console.log("Created issue: " + issue.fields.summary);
})
//console.log(util.inspect(issue, false, null));
})
});