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 Details

  • Method Details

    • 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 project
      name - 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 key
      version - The replacement version
      query - 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 Project
      fromVersion - The name of the version to replace
      toVersion - The name of the replacement version
      query - 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 Project
      version - The version to add
      query - 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