Skip to content

Added ability to pull all issues in a project #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Find the status of an issue.
console.log('Status: ' + issue.fields.status.name);
});

Currently there is no explicit login call necessary as each API call uses Basic Authentication to authenticate.
Currently there is no explicit login call necessary as each API call uses Basic Authentication to authenticate.

## Options ##

Expand All @@ -61,6 +61,7 @@ JiraApi options:
* List Components
* List Fields
* List Priorities
* Pulling all issues in project
* Versions
* Pulling versions
* Adding a new version
Expand Down
227 changes: 138 additions & 89 deletions lib/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
// * Versions
// * Pulling versions
// * Adding a new version
// * Updating a version
// * Pulling unresolved issues count for a specific version
// * Rapid Views
// * Find based on project name
Expand Down Expand Up @@ -98,6 +99,7 @@
// ## Changelog ##
//
//
// * _0.10.0 Add Update Version (thanks to [floralvikings](https://github.com/floralvikings))_
// * _0.9.0 Add OAuth Support and New Estimates on addWorklog (thanks to
// [nagyv](https://github.com/nagyv))_
// * _0.8.2 Fix URL Format Issues (thanks to
Expand Down Expand Up @@ -237,6 +239,53 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
});
};


// ## Get all issues in project ##
// ### Takes ###
//
// * project: key for the project
// * callback: for when it's done
//
// ### Returns ###
//
// * error: string of the error
// * project: the json object representing all issues in given project
//
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290709)
this.getProjectIssues = function(project, callback) {

var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/search?jql=project="' + project + '"'),
method: 'GET'
};

this.doRequest(options, function(error, response, body) {

if (error) {
callback(error, null);
return;
}

if (response.statusCode === 404) {
callback('Invalid issue number.');
return;
}

if (response.statusCode !== 200) {
callback(response.statusCode + ': Unable to connect to JIRA during findIssueStatus.');
return;
}

if (body === undefined) {
callback('Response body was undefined.');
}

callback(null, JSON.parse(body));

});
};

// ## Get the unresolved issue count ##
// ### Takes ###
//
Expand Down Expand Up @@ -1741,94 +1790,94 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
};

// ## Retrieve the backlog of a certain Rapid View ##
// ### Takes ###
// * rapidViewId: rapid view id
// * callback: for when it's done
//
// ### Returns ###
// * error string
// * backlog object
/*
* Backlog item is in the format:
* {
* "sprintMarkersMigrated": true,
* "issues": [
* {
* "id": 67890,
* "key": "KEY-1234",
* "summary": "Issue Summary",
* ...
* }
* ],
* "rankCustomFieldId": 12345,
* "sprints": [
* {
* "id": 123,
* "name": "Sprint Name",
* "state": "FUTURE",
* ...
* }
* ],
* "supportsPages": true,
* "projects": [
* {
* "id": 567,
* "key": "KEY",
* "name": "Project Name"
* }
* ],
* "epicData": {
* "epics": [
* {
* "id": 9876,
* "key": "KEY-4554",
* "typeName": "Epic",
* ...
* }
* ],
* "canEditEpics": true,
* "supportsPages": true
* },
* "canManageSprints": true,
* "maxIssuesExceeded": false,
* "queryResultLimit": 2147483647,
* "versionData": {
* "versionsPerProject": {
* "567": [
* {
* "id": 8282,
* "name": "Version Name",
* ...
* }
* ]
* },
* "canCreateVersion": true
* }
* }
*/
this.getBacklogForRapidView = function(rapidViewId, callback) {
var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/xboard/plan/backlog/data?rapidViewId=' + rapidViewId, 'rest/greenhopper/'),
method: 'GET',
json: true
};

this.doRequest(options, function(error, response) {
if (error) {
callback(error, null);

return;
}

if (response.statusCode === 200) {
callback(null, response.body);

return;
}

callback(response.statusCode + ': Error while retrieving backlog');
});
};
// ### Takes ###
// * rapidViewId: rapid view id
// * callback: for when it's done
//
// ### Returns ###
// * error string
// * backlog object
/*
* Backlog item is in the format:
* {
* "sprintMarkersMigrated": true,
* "issues": [
* {
* "id": 67890,
* "key": "KEY-1234",
* "summary": "Issue Summary",
* ...
* }
* ],
* "rankCustomFieldId": 12345,
* "sprints": [
* {
* "id": 123,
* "name": "Sprint Name",
* "state": "FUTURE",
* ...
* }
* ],
* "supportsPages": true,
* "projects": [
* {
* "id": 567,
* "key": "KEY",
* "name": "Project Name"
* }
* ],
* "epicData": {
* "epics": [
* {
* "id": 9876,
* "key": "KEY-4554",
* "typeName": "Epic",
* ...
* }
* ],
* "canEditEpics": true,
* "supportsPages": true
* },
* "canManageSprints": true,
* "maxIssuesExceeded": false,
* "queryResultLimit": 2147483647,
* "versionData": {
* "versionsPerProject": {
* "567": [
* {
* "id": 8282,
* "name": "Version Name",
* ...
* }
* ]
* },
* "canCreateVersion": true
* }
* }
*/
this.getBacklogForRapidView = function(rapidViewId, callback) {
var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/xboard/plan/backlog/data?rapidViewId=' + rapidViewId, 'rest/greenhopper/'),
method: 'GET',
json: true
};

this.doRequest(options, function(error, response) {
if (error) {
callback(error, null);

return;
}

if (response.statusCode === 200) {
callback(null, response.body);

return;
}

callback(response.statusCode + ': Error while retrieving backlog');
});
};

}).call(JiraApi.prototype);