Just remember to add ‘includeFutureSprints=true‘ if you need to find out the future Sprint. By default, it is only up to current Active sprint. Here is a nodejs sample:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Jira sprint query sample | |
* Find out current sprint and next sprint | |
*/ | |
'use strict' | |
const Promise = require('promise') | |
const request = require('request') | |
const lodash = require('lodash') | |
let options = { | |
headers: { "Content-Type": "application/json" }, | |
auth: { | |
user: process.env.USERNAME, | |
password: process.env.PASSWORD | |
} | |
}; | |
function findSprints (jiraURL, rapidViewId) { | |
return new Promise(function (resolve, reject) { | |
options.url = jiraURL + '/rest/greenhopper/1.0/sprintquery/' + rapidViewId + '?includeFutureSprints=true' | |
request.get (options, function(err, res, sprints) { | |
if (err) { | |
reject(err) | |
} else { | |
resolve(sprints) | |
} | |
}) | |
}) | |
} | |
async function printSprints (jiraURL, rapidViewId) { | |
const sprints = await findSprints(jiraURL, rapidViewId) | |
const activeSprint = lodash.filter(sprints.sprints, { state: 'ACTIVE' }) | |
const activeSprintId = activeSprint[0].id | |
const activeSprintName = activeSprint[0].name | |
const nextSprintId = sprints.sprints[sprints.sprints.indexOf(activeSprint[0]) + 1].id | |
const nextSprintName = sprints.sprints[sprints.sprints.indexOf(activeSprint[0]) + 1].name | |
console.log('Current sprint is:', activeSprintId, activeSprintName) | |
console.log('Next sprint is:', nextSprintId, nextSprintName) | |
} | |
const jiraURL = process.env.JIRA | |
const rapidViewId = '12345' | |
printSprints(jiraURL, rapidViewId) |
Advertisement