daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest May 16th, 2018 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.jirasandbox;
  2.  
  3. import com.atlassian.jira.rest.client.api.JiraRestClient;
  4. import com.atlassian.jira.rest.client.api.JiraRestClientFactory;
  5. import com.atlassian.jira.rest.client.api.domain.BasicProject;
  6. import com.atlassian.jira.rest.client.api.domain.Issue;
  7. import com.atlassian.jira.rest.client.api.domain.SearchResult;
  8. import com.atlassian.jira.rest.client.api.domain.User;
  9. import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
  10. import com.atlassian.util.concurrent.Promise;
  11. import java.net.URI;
  12.  
  13. public class CustomJiraRestClient {
  14.  
  15.     private static final String JIRA_URL = "http://jira-dev:8080";
  16.     private static final String JIRA_ADMIN_USERNAME = "admin";
  17.     private static final String JIRA_ADMIN_PASSWORD = "admin";
  18.  
  19.     public static void main(String[] args) throws Exception {
  20.         // Construct the JRJC client
  21.         System.out.println(String.format("Logging in to %s with username '%s' and password '%s'", JIRA_URL, JIRA_ADMIN_USERNAME, JIRA_ADMIN_PASSWORD));
  22.         JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
  23.         URI uri = new URI(JIRA_URL);
  24.         JiraRestClient client = factory.createWithBasicHttpAuthentication(uri, JIRA_ADMIN_USERNAME, JIRA_ADMIN_PASSWORD);
  25.  
  26.         // Invoke the JRJC Client
  27.         Promise<User> promise = client.getUserClient().getUser("admin");
  28.         User user = promise.claim();
  29.  
  30.         for (BasicProject project : client.getProjectClient().getAllProjects().claim()) {
  31.             System.out.println(project.getKey() + ": " + project.getName());
  32.         }
  33.  
  34.         Promise<SearchResult> searchJqlPromise = client.getSearchClient().searchJql("project = MYPURRJECT AND status in (Closed, Completed, Resolved) ORDER BY assignee, resolutiondate");
  35.  
  36.         for (Issue issue : searchJqlPromise.claim().getIssues()) {
  37.             System.out.println(issue.getSummary());
  38.         }
  39.  
  40.         // Print the result
  41.         System.out.println(String.format("Your admin user's email address is: %srn", user.getEmailAddress()));
  42.  
  43.         // Done
  44.         System.out.println("Example complete. Now exiting.");
  45.         System.exit(0);
  46.     }
  47. }
RAW Paste Data
Top