@com.adaptavist.hapi.cloud.analytics.CloudTracked @com.onresolve.scriptrunner.hapi.annotation.Implements(parentInterface: IssuesApi) class Issues extends java.lang.Object
Utility class for managing and interacting with issues in Jira Cloud.
The Issues class provides methods to retrieve, create, count, and search issues within Jira.
1. Retrieve an issue by its key:
def issue = Issues.getByKey("TEST-123")
println "Issue Summary: ${issue.summary"
}
2. Create a new issue:
def issue = Issues.create("SR", "Task") {
summary = "Implement feature X"
description = "Detailed description of feature X"
println "Issue Created: ${issue.key}"
}
3. Count issues matching a JQL query:
def total = Issues.count("project = SR AND status = 'To Do'")
println "Total issues in To Do: $total"
4. Search for issues and update them:
Issues.search("project = SR AND status = 'To Do'").each {
it.update {
setLabels("updated-label")
println "Updated issue: ${it.key}"
}
} | Constructor and description |
|---|
Issues() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static long |
count(java.lang.String jql)Returns the number of matching issues. |
|
static Issue |
create(java.lang.String projectKey, java.lang.String issueTypeName, groovy.lang.Closure<?> specification)Creates an issue of a given type in a project found by project key, example usage:
Issues.create('SR', 'Task') {
summary = 'Hello world'
} |
|
static Issue |
getByKey(java.lang.String key)Retrieves an issue by its key. |
|
static IssueIterator |
search(java.lang.String jql)Executes the jql and returns matching issues. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Returns the number of matching issues.
jql - A jql queryCreates an issue of a given type in a project found by project key, example usage:
Issues.create('SR', 'Task') {
summary = 'Hello world'
}projectKey - project key of the project to create the issue inissueTypeName - issue type name for the issuespecification - closure containing parameters to set on the created issueRetrieves an issue by its key.
Fetches a single issue using its unique issue key. This method is useful when you know the issue key and want to retrieve details about that issue.
def issue = Issues.getByKey("SR-123")
println "Summary: ${issue.summary"
} key - the unique key of the issue (e.g., "SR-123")Executes the jql and returns matching issues. You can iterate over the issues in the response, for example to edit or transition each one:
Issues.search('project = FOO').each {
// do something with it
}
Or filter them further:
Issues.search('project = FOO').findAll {
// condition
}
If you only need the top N:
Issues.search('project = FOO').take(10)
DO NOT attempt to convert a potentially unlimited set to a List, e.g.:
Issues.search('project = FOO').toList()
as this could potentially consume a large amount of memory.
If you need a list then limit it to the top N:
Issues.search('project = FOO').take(100).toList()
jql - A jql query