Skip to content

Instantly share code, notes, and snippets.

@jamieechlin
Created July 22, 2013 11:26
Show Gist options
  • Save jamieechlin/6053166 to your computer and use it in GitHub Desktop.
Save jamieechlin/6053166 to your computer and use it in GitHub Desktop.
jql diagnostics
package examples
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import groovy.json.JsonSlurper
import org.apache.commons.httpclient.HttpClient
import org.apache.commons.httpclient.HttpMethod
import org.apache.commons.httpclient.methods.GetMethod
import org.apache.log4j.Logger
def log = Logger.getLogger("com.onresolve.jira.groovy.IssuesInSprintDiagnostics")
def sb = new StringBuilder()
def client = new HttpClient()
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
sb << "Base url is ${baseUrl}\n"
def url = "${baseUrl}/login.jsp"
HttpMethod method = new GetMethod(url)
def httpStatus = client.executeMethod(method)
method.releaseConnection()
sb << "Request to ${url} returned ${httpStatus}\n"
url = "${baseUrl}/rest/greenhopper/1.0/rapidviews/list"
method = new GetMethod(url)
httpStatus = client.executeMethod(method)
sb << "Request to ${url} returned ${httpStatus}\n"
def data = method.getResponseBodyAsStream().text
method.releaseConnection()
def json = new JsonSlurper().parseText(data) as Map
sb << "Available boards: " + json.get("views").collect {it["name"]} + "\n"
sb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment