Class JiraSite

All Implemented Interfaces:
Describable<JiraSite>

public class JiraSite extends AbstractDescribableImpl<JiraSite>
You must get instance of this only by using the static get(hudson.model.Job<?, ?>) or getSitesFromFolders(ItemGroup) methods The constructors are only used by Jenkins

Represents an external Jira installation and configuration needed to access this Jira.

When adding new fields do not miss to look at readResolve method!!
Author:
Kohsuke Kawaguchi
  • Field Details

    • DEFAULT_ISSUE_PATTERN

      public static final Pattern DEFAULT_ISSUE_PATTERN
      Regexp pattern that identifies Jira issue token. If this pattern changes help pages (help-issue-pattern_xy.html) must be updated First char must be a letter, then at least one letter, digit or underscore. See issue JENKINS-729, JENKINS-4092
    • DEFAULT_TIMEOUT

      public static final int DEFAULT_TIMEOUT
      Default rest api client calls timeout, in seconds See issue JENKINS-31113
      See Also:
    • DEFAULT_READ_TIMEOUT

      public static final int DEFAULT_READ_TIMEOUT
      See Also:
    • DEFAULT_THREAD_EXECUTOR_NUMBER

      public static final int DEFAULT_THREAD_EXECUTOR_NUMBER
      See Also:
    • DEFAULT_ISSUES_FROM_JQL

      public static final Integer DEFAULT_ISSUES_FROM_JQL
    • MAX_ALLOWED_ISSUES_FROM_JQL

      public static final Integer MAX_ALLOWED_ISSUES_FROM_JQL
    • url

      public final URL url
      URL of Jira for Jenkins access, like http://jira.codehaus.org/. Mandatory. Normalized to end with '/'
    • alternativeUrl

      public URL alternativeUrl
      URL of Jira for normal access, like http://jira.codehaus.org/. Mandatory. Normalized to end with '/'
    • useHTTPAuth

      public boolean useHTTPAuth
      Jira requires HTTP Authentication for login
    • credentialsId

      public String credentialsId
      The id of the credentials to use. Optional.
    • useBearerAuth

      public boolean useBearerAuth
      Jira requires Bearer Authentication for login
    • groupVisibility

      public String groupVisibility
      Group visibility to constrain the visibility of the added comment. Optional.
    • roleVisibility

      public String roleVisibility
      Role visibility to constrain the visibility of the added comment. Optional.
    • supportsWikiStyleComment

      public boolean supportsWikiStyleComment
      True if this Jira is configured to allow Confluence-style Wiki comment.
    • recordScmChanges

      public boolean recordScmChanges
      to record scm changes in jira issue
      Since:
      1.21
    • disableChangelogAnnotations

      public boolean disableChangelogAnnotations
      Disable annotating the changelogs
      Since:
      todo
    • updateJiraIssueForAllStatus

      public boolean updateJiraIssueForAllStatus
      updated jira issue for all status
      Since:
      1.22
    • timeout

      public int timeout
      connection timeout used when calling jira rest api, in seconds
  • Constructor Details

    • JiraSite

      @Deprecated public JiraSite(URL url, @CheckForNull URL alternativeUrl, @CheckForNull String credentialsId, boolean supportsWikiStyleComment, boolean recordScmChanges, @CheckForNull String userPattern, boolean updateJiraIssueForAllStatus, @CheckForNull String groupVisibility, @CheckForNull String roleVisibility, boolean useHTTPAuth)
      Deprecated.
    • JiraSite

      @Deprecated public JiraSite(URL url, @CheckForNull URL alternativeUrl, String userName, String password, boolean supportsWikiStyleComment, boolean recordScmChanges, @CheckForNull String userPattern, boolean updateJiraIssueForAllStatus, @CheckForNull String groupVisibility, @CheckForNull String roleVisibility, boolean useHTTPAuth) throws Descriptor.FormException
      Deprecated.
      Throws:
      Descriptor.FormException
    • JiraSite

      @Deprecated public JiraSite(URL url, URL alternativeUrl, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials, boolean supportsWikiStyleComment, boolean recordScmChanges, String userPattern, boolean updateJiraIssueForAllStatus, String groupVisibility, String roleVisibility, boolean useHTTPAuth) throws Descriptor.FormException
      Deprecated.
      Throws:
      Descriptor.FormException
    • JiraSite

      @Deprecated public JiraSite(URL url, URL alternativeUrl, String credentialsId, boolean supportsWikiStyleComment, boolean recordScmChanges, String userPattern, boolean updateJiraIssueForAllStatus, String groupVisibility, String roleVisibility, boolean useHTTPAuth, int timeout, int readTimeout, int threadExecutorNumber)
      Deprecated.
    • JiraSite

      @DataBoundConstructor public JiraSite(String url)
    • JiraSite

      @Deprecated public JiraSite(URL url, URL alternativeUrl, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials, boolean supportsWikiStyleComment, boolean recordScmChanges, String userPattern, boolean updateJiraIssueForAllStatus, String groupVisibility, String roleVisibility, boolean useHTTPAuth, int timeout, int readTimeout, int threadExecutorNumber)
      Deprecated.
    • JiraSite

      @Deprecated public JiraSite(URL url, URL alternativeUrl, com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials credentials, boolean supportsWikiStyleComment, boolean recordScmChanges, String userPattern, boolean updateJiraIssueForAllStatus, String groupVisibility, String roleVisibility, boolean useHTTPAuth, int timeout, int readTimeout, int threadExecutorNumber, boolean useBearerAuth)
      Deprecated.
  • Method Details

    • setDisableChangelogAnnotations

      @DataBoundSetter public void setDisableChangelogAnnotations(boolean disableChangelogAnnotations)
    • getDisableChangelogAnnotations

      public boolean getDisableChangelogAnnotations()
    • setTimeout

      @DataBoundSetter public void setTimeout(int timeoutSec)
      Sets connect timeout (in seconds). If not specified, a default timeout will be used.
      Parameters:
      timeoutSec - Timeout in seconds
    • getTimeout

      public int getTimeout()
    • setReadTimeout

      @DataBoundSetter public void setReadTimeout(int readTimeout)
      Sets read timeout (in seconds). If not specified, a default timeout will be used.
      Parameters:
      readTimeout - Timeout in seconds
    • getReadTimeout

      public int getReadTimeout()
    • getCredentialsId

      public String getCredentialsId()
    • setCredentialsId

      @DataBoundSetter public void setCredentialsId(String credentialsId)
    • setDateTimePattern

      @DataBoundSetter public void setDateTimePattern(String dateTimePattern)
    • setThreadExecutorNumber

      @DataBoundSetter public void setThreadExecutorNumber(int threadExecutorNumber)
    • getThreadExecutorNumber

      public int getThreadExecutorNumber()
    • setAppendChangeTimestamp

      @DataBoundSetter public void setAppendChangeTimestamp(boolean appendChangeTimestamp)
    • getDateTimePattern

      public String getDateTimePattern()
    • isAppendChangeTimestamp

      public boolean isAppendChangeTimestamp()
    • getAlternativeUrl

      public URL getAlternativeUrl()
    • isUseHTTPAuth

      public boolean isUseHTTPAuth()
    • isUseBearerAuth

      public boolean isUseBearerAuth()
    • getGroupVisibility

      public String getGroupVisibility()
    • getRoleVisibility

      public String getRoleVisibility()
    • isSupportsWikiStyleComment

      public boolean isSupportsWikiStyleComment()
    • isRecordScmChanges

      public boolean isRecordScmChanges()
    • isUpdateJiraIssueForAllStatus

      public boolean isUpdateJiraIssueForAllStatus()
    • setAlternativeUrl

      @DataBoundSetter public void setAlternativeUrl(String alternativeUrl)
    • setUseHTTPAuth

      @DataBoundSetter public void setUseHTTPAuth(boolean useHTTPAuth)
    • setUseBearerAuth

      @DataBoundSetter public void setUseBearerAuth(boolean useBearerAuth)
    • setGroupVisibility

      @DataBoundSetter public void setGroupVisibility(String groupVisibility)
    • setRoleVisibility

      @DataBoundSetter public void setRoleVisibility(String roleVisibility)
    • setSupportsWikiStyleComment

      @DataBoundSetter public void setSupportsWikiStyleComment(boolean supportsWikiStyleComment)
    • setRecordScmChanges

      @DataBoundSetter public void setRecordScmChanges(boolean recordScmChanges)
    • setUserPattern

      @DataBoundSetter public void setUserPattern(String userPattern)
    • setUpdateJiraIssueForAllStatus

      @DataBoundSetter public void setUpdateJiraIssueForAllStatus(boolean updateJiraIssueForAllStatus)
    • setMaxIssuesFromJqlSearch

      @DataBoundSetter public void setMaxIssuesFromJqlSearch(int maxIssuesFromJqlSearch)
    • getMaxIssuesFromJqlSearch

      public int getMaxIssuesFromJqlSearch()
    • readResolve

      protected Object readResolve() throws Descriptor.FormException
      Throws:
      Descriptor.FormException
    • makeIssueCache

      protected static com.github.benmanes.caffeine.cache.Cache<String,Optional<com.atlassian.jira.rest.client.api.domain.Issue>> makeIssueCache()
    • getName

      public String getName()
    • getSession

      @Deprecated public JiraSession getSession()
      Deprecated.
      should not be used
    • getSession

      @Nullable public JiraSession getSession(Item item)
      Gets a remote access session to this Jira site (job-aware) Creates one if none exists already.
      Returns:
      null if remote access is not supported.
    • getHttpClientOptions

      protected com.atlassian.httpclient.api.factory.HttpClientOptions getHttpClientOptions()
    • destroy

      @PreDestroy public void destroy()
    • getUrl

      @Nullable public URL getUrl()
      Returns:
      the server URL
    • getUrl

      public URL getUrl(JiraIssue issue) throws IOException
      Computes the URL to the given issue.
      Throws:
      IOException
    • getUrl

      public URL getUrl(String id) throws MalformedURLException
      Computes the URL to the given issue.
      Throws:
      MalformedURLException
    • getAlternativeUrl

      public URL getAlternativeUrl(String id) throws MalformedURLException
      Computes the alternative link URL to the given issue.
      Throws:
      MalformedURLException
    • getUserPattern

      public Pattern getUserPattern()
      Gets the user-defined issue pattern if any.
      Returns:
      the pattern or null
    • getIssuePattern

      public Pattern getIssuePattern()
    • getProjectKeys

      public Set<String> getProjectKeys(Item item)
      Gets the list of project IDs in this Jira. This information could be bit old, or it can be null.
    • getIssue

      @CheckForNull public JiraIssue getIssue(String id) throws IOException
      Returns the remote issue with the given id or null if it wasn't found.
      Throws:
      IOException
    • existsIssue

      @Deprecated public boolean existsIssue(String id)
      Deprecated.
    • getVersions

      @Deprecated public Set<ExtendedVersion> getVersions(String projectKey)
      Returns all versions for the given project key.
      Parameters:
      projectKey - Project Key
      Returns:
      A set of JiraVersions
    • getReleaseNotesForFixVersion

      public String getReleaseNotesForFixVersion(String projectKey, String versionName, String filter) throws TimeoutException
      Generates release notes for a given version.
      Parameters:
      projectKey - the project key
      versionName - the version
      filter - Additional JQL Filter. Example: status in (Resolved,Closed)
      Returns:
      release notes
      Throws:
      TimeoutException - if too long
    • replaceFixVersion

      public void replaceFixVersion(String projectKey, String fromVersion, String toVersion, String query) throws TimeoutException
      Migrates issues matching the jql query provided to a new fix version.
      Parameters:
      projectKey - The project key
      toVersion - The new fixVersion
      query - A JQL Query
      Throws:
      TimeoutException - if too long
    • migrateIssuesToFixVersion

      public void migrateIssuesToFixVersion(String projectKey, String versionName, String query) throws TimeoutException
      Migrates issues matching the jql query provided to a new fix version.
      Parameters:
      projectKey - The project key
      versionName - The new fixVersion
      query - A JQL Query
      Throws:
      TimeoutException - if too long
    • addFixVersionToIssue

      public void addFixVersionToIssue(String projectKey, String versionName, String query) throws TimeoutException
      Adds new fix version to issues matching the jql.
      Parameters:
      projectKey - the project key
      versionName - the version
      query - the query
      Throws:
      TimeoutException - if too long
    • progressMatchingIssues

      public boolean progressMatchingIssues(String jqlSearch, String workflowActionName, String comment, PrintStream console) throws TimeoutException
      Progresses all issues matching the JQL search, using the given workflow action. Optionally adds a comment to the issue(s) at the same time.
      Parameters:
      jqlSearch - the query
      workflowActionName - the workflowActionName
      comment - the comment
      console - the console
      Throws:
      TimeoutException - TimeoutException if too long
    • map

      public static ItemGroup map(Item item)
      Parameters:
      item - the Jenkins Item can be a Job or Folder
      Returns:
      the parent as ItemGroup which can be Jenkins or Folder
    • getJiraSites

      public static List<JiraSite> getJiraSites(Item item)
      Creates automatically jiraSession for each jiraSite found
    • getSitesFromFolders

      public static List<JiraSite> getSitesFromFolders(ItemGroup itemGroup)
      Creates automatically jiraSession for each jiraSite found
    • get

      @Nullable public static JiraSite get(Job<?,?> p)
      Gets the effective JiraSite associated with the given project and creates automatically jiraSession for each jiraSite found
      Returns:
      null if no such was found.