commit
62ecc175ca
56
server.js
56
server.js
|
@ -355,6 +355,62 @@ cache(function (data, match, sendBadge, request) {
|
|||
});
|
||||
}));
|
||||
|
||||
// JIRA agile sprint completion integration
|
||||
camp.route(/^\/jira\/sprint\/(http(?:s)?)\/(.+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/,
|
||||
cache(function (data, match, sendBadge, request) {
|
||||
var protocol = match[1]; // eg, https
|
||||
var host = match[2]; // eg, jira.spring.io
|
||||
var sprintId = match[3]; // eg, 94
|
||||
var format = match[4]; // eg, png
|
||||
|
||||
var options = {
|
||||
method: 'GET',
|
||||
json: true,
|
||||
uri: protocol + '://' + host + '/rest/api/2/search?jql=sprint='+sprintId+'%20AND%20type%20IN%20(Bug,Improvement,Story,"Technical%20task")&fields=resolution&maxResults=500'
|
||||
};
|
||||
if (serverSecrets && serverSecrets.jira_username) {
|
||||
options.auth = {
|
||||
user: serverSecrets.jira_username,
|
||||
pass: serverSecrets.jira_password
|
||||
};
|
||||
}
|
||||
|
||||
var badgeData = getBadgeData('completion', data);
|
||||
request(options, function (err, res, json) {
|
||||
if (err != null) {
|
||||
badgeData.text[1] = 'inaccessible';
|
||||
sendBadge(format, badgeData);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (json && json.total >= 0) {
|
||||
var issuesDone = json.issues.filter(function (el) {
|
||||
if (el.fields.resolution != null) {
|
||||
return el.fields.resolution.name !== "Unresolved";
|
||||
}
|
||||
}).length;
|
||||
badgeData.text[1] = Math.round(issuesDone * 100 / json.total) + "%";
|
||||
switch(issuesDone) {
|
||||
case 0:
|
||||
badgeData.colorscheme = 'red';
|
||||
break;
|
||||
case json.total:
|
||||
badgeData.colorscheme = 'brightgreen';
|
||||
break;
|
||||
default:
|
||||
badgeData.colorscheme = 'orange';
|
||||
}
|
||||
} else {
|
||||
badgeData.text[1] = 'invalid';
|
||||
}
|
||||
sendBadge(format, badgeData);
|
||||
} catch (e) {
|
||||
badgeData.text[1] = 'invalid';
|
||||
sendBadge(format, badgeData);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
// Travis integration
|
||||
camp.route(/^\/travis(-ci)?\/([^\/]+\/[^\/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,
|
||||
cache(function(data, match, sendBadge, request) {
|
||||
|
|
7
try.html
7
try.html
|
@ -846,6 +846,10 @@ Pixel-perfect Retina-ready Fast Consistent Hackable
|
|||
<td><img src='/jira/issue/https/issues.apache.org/jira/KAFKA-2896.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/jira/issue/https/issues.apache.org/jira/KAFKA-2896.svg</code></td>
|
||||
</tr>
|
||||
<tr><th data-doc='jira-sprint-completion'> JIRA sprint completion: </th>
|
||||
<td><img src='/jira/sprint/https/jira.spring.io/94.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/jira/sprint/https/jira.spring.io/94.svg</code></td>
|
||||
</tr>
|
||||
<tr><th> Maintenance: </th>
|
||||
<td><img src='/maintenance/yes/2016.svg' alt=''/></td>
|
||||
<td><code>https://img.shields.io/maintenance/yes/2016.svg</code></td>
|
||||
|
@ -1181,6 +1185,9 @@ is where the current server got started.
|
|||
to add Shields as a GitHub application on your GitHub account.
|
||||
</p>
|
||||
</div>
|
||||
<div id="jira-sprint-completion">
|
||||
<p>To get the <code>Sprint ID</code>, go to your Backlog view in your project, right click on your sprint name and get the value of <code>data-sprint-id</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<svg style='height:0'>
|
||||
|
|
Loading…
Reference in New Issue
Block a user