Package hudson.plugins.jira
Class JiraSession
- java.lang.Object
-
- hudson.plugins.jira.JiraSession
-
public class JiraSession extends Object
Connection to Jira. Jira has a built-in timeout for a session, so after some inactive period the session will become invalid. The caller must make sure that this doesn't happen.- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
Fields Modifier and Type Field Description JiraRestService
service
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addComment(String issueId, String comment, String groupVisibility, String roleVisibility)
Adds a comment to the existing issue.void
addCommentWithoutConstrains(String issueId, String comment)
Adds a comment to the existing issue.There is no constrains to the visibility of the comment.void
addFields(String issueId, List<JiraIssueField> fields)
Adds new to or updates existing fields of the issue.void
addFixVersion(String projectKey, String version, String query)
Adds the specified version to the fix version list of all issues matching the JQL.void
addLabels(String issueId, List<String> labels)
Adds new labels to the existing issue.com.atlassian.jira.rest.client.api.domain.Version
addVersion(String version, String projectKey)
Creates a new version and returns itcom.atlassian.jira.rest.client.api.domain.Issue
createIssue(String projectKey, String description, String assignee, Iterable<String> components, String summary)
Deprecated.com.atlassian.jira.rest.client.api.domain.Issue
createIssue(String projectKey, String description, String assignee, Iterable<String> components, String summary, Long issueTypeId, Long priorityId)
Integer
getActionIdForIssue(String issueKey, String workflowAction)
Returns the matching action id for a given action name.List<com.atlassian.jira.rest.client.api.domain.Component>
getComponents(String projectKey)
Returns all the components for the particular projectcom.atlassian.jira.rest.client.api.domain.Issue
getIssue(String id)
Gets the details of one issue.com.atlassian.jira.rest.client.api.domain.Issue
getIssueByKey(String issueId)
Returns information about the specific issue as identified by the issue idList<com.atlassian.jira.rest.client.api.domain.Issue>
getIssuesFromJqlSearch(String jqlSearch)
Gets all issues that match the given JQL filterList<com.atlassian.jira.rest.client.api.domain.Issue>
getIssuesWithFixVersion(String projectKey, String version)
List<com.atlassian.jira.rest.client.api.domain.Issue>
getIssuesWithFixVersion(String projectKey, String version, String filter)
List<com.atlassian.jira.rest.client.api.domain.IssueType>
getIssueTypes()
Get all issue typescom.atlassian.jira.rest.client.api.domain.Permissions
getMyPermissions()
Get User's permissionsList<com.atlassian.jira.rest.client.api.domain.Priority>
getPriorities()
Get all prioritiesSet<String>
getProjectKeys()
Returns the set of project keys (like MNG, JENKINS, etc) that are available in this Jira.String
getStatusById(Long statusId)
Returns the status name by status id.ExtendedVersion
getVersionByName(String projectKey, String name)
Get a version by its nameList<ExtendedVersion>
getVersions(String projectKey)
Get all versions from the given projectvoid
migrateIssuesToFixVersion(String projectKey, String version, String query)
Replaces the fix version list of all issues matching the JQL Query with the version specified.String
progressWorkflowAction(String issueKey, Integer actionId)
Progresses the issue's workflow by performing the specified action.void
releaseVersion(String projectKey, ExtendedVersion version)
Release given version in given projectvoid
replaceFixVersion(String projectKey, String fromVersion, String toVersion, String query)
Replaces the given fromVersion with toVersion in all issues matching the JQL query.
-
-
-
Field Detail
-
service
public final JiraRestService service
-
-
Method Detail
-
getProjectKeys
public Set<String> getProjectKeys()
Returns the set of project keys (like MNG, JENKINS, etc) that are available in this Jira. Guarantees to return all project keys in upper case.
-
addComment
public void addComment(String issueId, String comment, String groupVisibility, String roleVisibility)
Adds a comment to the existing issue. Constrains the visibility of the comment the the supplied groupVisibility.
-
addLabels
public void addLabels(String issueId, List<String> labels)
Adds new labels to the existing issue. Old labels remains untouched.- Parameters:
issueId
- Jira issue ID like "MNG-1235".labels
- New labels to add.
-
addFields
public void addFields(String issueId, List<JiraIssueField> fields)
Adds new to or updates existing fields of the issue. Can add or update custom fields.- Parameters:
issueId
- Jira issue ID like "PRJ-123"fields
- Fields to add or update
-
getIssue
public com.atlassian.jira.rest.client.api.domain.Issue getIssue(String id)
Gets the details of one issue.- Parameters:
id
- Issue ID like "MNG-1235".- Returns:
- null if no such issue exists.
-
getIssuesFromJqlSearch
public List<com.atlassian.jira.rest.client.api.domain.Issue> getIssuesFromJqlSearch(String jqlSearch) throws TimeoutException
Gets all issues that match the given JQL filter- Parameters:
jqlSearch
- JQL query string to execute- Returns:
- issues matching the JQL query
- Throws:
TimeoutException
-
getVersions
public List<ExtendedVersion> getVersions(String projectKey)
Get all versions from the given project- Parameters:
projectKey
- The key for the project- Returns:
- An array of versions
-
getVersionByName
public ExtendedVersion getVersionByName(String projectKey, String name)
Get a version by its name- Parameters:
projectKey
- The key for the projectname
- The version name- Returns:
- A RemoteVersion, or null if not found
-
getIssuesWithFixVersion
public List<com.atlassian.jira.rest.client.api.domain.Issue> getIssuesWithFixVersion(String projectKey, String version) throws TimeoutException
- Throws:
TimeoutException
-
getIssuesWithFixVersion
public List<com.atlassian.jira.rest.client.api.domain.Issue> getIssuesWithFixVersion(String projectKey, String version, String filter) throws TimeoutException
- Throws:
TimeoutException
-
getIssueTypes
public List<com.atlassian.jira.rest.client.api.domain.IssueType> getIssueTypes()
Get all issue types- Returns:
- An array of issue types
-
getPriorities
public List<com.atlassian.jira.rest.client.api.domain.Priority> getPriorities()
Get all priorities- Returns:
- An array of priorities
-
releaseVersion
public void releaseVersion(String projectKey, ExtendedVersion version)
Release given version in given project
-
migrateIssuesToFixVersion
public void migrateIssuesToFixVersion(String projectKey, String version, String query) throws TimeoutException
Replaces the fix version list of all issues matching the JQL Query with the version specified.- Parameters:
projectKey
- The Jira Project keyversion
- The replacement versionquery
- The JQL Query- Throws:
TimeoutException
-
replaceFixVersion
public void replaceFixVersion(String projectKey, String fromVersion, String toVersion, String query) throws TimeoutException
Replaces the given fromVersion with toVersion in all issues matching the JQL query.- Parameters:
projectKey
- The Jira ProjectfromVersion
- The name of the version to replacetoVersion
- The name of the replacement versionquery
- The JQL Query- Throws:
TimeoutException
-
addFixVersion
public void addFixVersion(String projectKey, String version, String query) throws TimeoutException
Adds the specified version to the fix version list of all issues matching the JQL.- Parameters:
projectKey
- The Jira Projectversion
- The version to addquery
- The JQL Query- Throws:
TimeoutException
-
progressWorkflowAction
public String progressWorkflowAction(String issueKey, Integer actionId)
Progresses the issue's workflow by performing the specified action. The issue's new status is returned.- Returns:
- The new status
-
getActionIdForIssue
public Integer getActionIdForIssue(String issueKey, String workflowAction)
Returns the matching action id for a given action name.- Returns:
- The action id, or null if the action cannot be found.
-
getStatusById
public String getStatusById(Long statusId)
Returns the status name by status id.- Returns:
- status name
-
createIssue
@Deprecated public com.atlassian.jira.rest.client.api.domain.Issue createIssue(String projectKey, String description, String assignee, Iterable<String> components, String summary)
Deprecated.Returns issue-id of the created issue- Returns:
- The issue id
-
createIssue
public com.atlassian.jira.rest.client.api.domain.Issue createIssue(String projectKey, String description, String assignee, Iterable<String> components, String summary, @NonNull Long issueTypeId, @Nullable Long priorityId)
-
addCommentWithoutConstrains
public void addCommentWithoutConstrains(String issueId, String comment)
Adds a comment to the existing issue.There is no constrains to the visibility of the comment.
-
getIssueByKey
public com.atlassian.jira.rest.client.api.domain.Issue getIssueByKey(String issueId)
Returns information about the specific issue as identified by the issue id- Returns:
- issue object
-
getComponents
public List<com.atlassian.jira.rest.client.api.domain.Component> getComponents(String projectKey)
Returns all the components for the particular project- Returns:
- An array of components
-
addVersion
public com.atlassian.jira.rest.client.api.domain.Version addVersion(String version, String projectKey)
Creates a new version and returns it- Parameters:
version
- version id to create- Returns:
- created Version instance
-
getMyPermissions
public com.atlassian.jira.rest.client.api.domain.Permissions getMyPermissions()
Get User's permissions
-
-