예제 #1
0
 public JiraTickets tickets() throws ExecutionException, InterruptedException {
   List<JiraTicket> jiraTickets = new ArrayList<JiraTicket>();
   for (BasicIssue issuesKey : issuesKeys) {
     Promise<Issue> issuePromise = issueRestClient.getIssue(issuesKey.getKey());
     Issue i = issuePromise.get();
     JiraTicket ticket =
         new JiraTicket(
             i.getKey(),
             field(i, HOTFIX_TO),
             field(i, FIX_DETAILS),
             field(i, HOTFIX_FILES),
             field(i, HOTFIX_INSTRUCTIONS),
             field(i, HOTFIX_APPROVED_BY),
             field(i, VERIFICATION_DETAILS));
     jiraTickets.add(ticket);
   }
   return new JiraTickets(jiraTickets);
 }
예제 #2
0
 private String field(Issue issue, TicketFields filed) {
   Field field = issue.getFieldByName(filed.getName());
   if (field != null) {
     Object fieldValue = field.getValue();
     if (fieldValue != null) {
       return fieldValue.toString();
     }
   }
   return "";
 }
예제 #3
0
  public void uploadAttachments(JiraTickets tickets)
      throws ExecutionException, InterruptedException, IOException {
    for (JiraTicket t : tickets) {
      Promise<Issue> issuePromise = issueRestClient.getIssue(t.getId());
      Issue i = issuePromise.get();
      File rollback = t.getRollback();
      File hotfix = t.getHotfix();

      if (rollback != null && rollback.canRead()) {
        issueRestClient.addAttachment(
            i.getAttachmentsUri(), FileUtils.openInputStream(rollback), rollback.getName());
      }

      if (hotfix != null && hotfix.canRead()) {
        issueRestClient.addAttachment(
            i.getAttachmentsUri(), FileUtils.openInputStream(hotfix), hotfix.getName());
      }
    }
  }
예제 #4
0
 public void updateTickets(JiraTickets tickets) throws ExecutionException, InterruptedException {
   for (JiraTicket t : tickets) {
     Promise<Issue> issuePromise = issueRestClient.getIssue(t.getId());
     Issue i = issuePromise.get();
     // find transition (we need ID)
     Iterable<Transition> transitions =
         issueRestClient.getTransitions(i.getTransitionsUri()).get();
     String tName = "Hotfix Failed";
     if (t.isValid()) {
       tName = "Out On Dev";
     }
     Transition transition = find(transitions, tName);
     if (transition == null) {
       continue;
     }
     // prepare fields
     // List<FieldInput> fields = Arrays.asList(   new FieldInput("resolution",
     // ComplexIssueInputFieldValue.with("name", "RerunPass")));
     Comment comment = Comment.valueOf(StringUtils.join(t.getValidationMessages(), "\n"));
     issueRestClient.transition(i, new TransitionInput(transition.getId(), comment));
   }
 }
예제 #5
0
  public static void main(String[] args) throws Exception {

    String jiraUser = args[0];
    String jiraPassword = args[1];
    String wikiUser = args[2];
    String wikiPassword = args[3];
    String issueProject = args[4];
    String issueFixVersion = args[5];
    String sprintNumber = args[6];
    String createdAfter = args[7];
    String buildVersion = args[8];
    String sinceVersion = args[9];

    JiraClient jiraClient = new JiraClient(jiraUser, jiraPassword);
    String issueType = "";
    String issueResolution = "";
    String issueStatus = "";

    String tempCreatedAfter = createdAfter;
    String tempIssueFixVersion = issueFixVersion;

    ObjectMapper mapper = new ObjectMapper();

    WikiClient wikiClient =
        new WikiClient("http://wiki.gigaspaces.com/wiki", wikiUser, wikiPassword);

    System.out.println("Connected ok.");
    ConfluenceSoapService service = wikiClient.getConfluenceSOAPService();
    String token = wikiClient.getToken();

    RemoteServerInfo info = service.getServerInfo(token);
    System.out.println(
        "Confluence version: " + info.getMajorVersion() + "." + info.getMinorVersion());
    System.out.println("Completed.");

    String cutBuildVersion = buildVersion.substring(0, buildVersion.length() - 1);
    String pageTitle = "GigaSpaces XAP " + cutBuildVersion + "X Release Notes";

    RemotePage page = service.getPage(token, "RN", pageTitle);
    String pageContent = page.getContent();
    String[] cards = {
      "{card:label=Known Issues & Limitations}",
      "{card:label=Fixed Issues}",
      "{card:label=New Features and Improvements}"
    };
    String[] headlines = {
      "{card:label=Known Issues & Limitations}\n"
          + "|| Key || Summary || SalesForce ID || Since version || Workaround || Platform/s ||",
      "{card:label=Fixed Issues}\n"
          + "|| Key || Summary || Fixed in Version || SalesForce ID || Platform/s ||",
      "{card:label=New Features and Improvements}\n"
          + "|| Key || Summary || Since Version || SalesForce ID || Documentation Link || Platform/s ||"
    };
    int headlineIndex = 0;
    for (String card : cards) {
      int cardStartIndex = pageContent.indexOf(headlines[headlineIndex]);
      int cardEndIndex = pageContent.indexOf("\n{card}", cardStartIndex);
      String cardSubstring =
          pageContent.substring(cardStartIndex + headlines[headlineIndex].length(), cardEndIndex);
      pageContent = pageContent.replace(cardSubstring, "");
      headlineIndex++;
    }

    for (int i = 0; i < 3; i++) {

      // Fixed issues
      if (i == 0) {
        issueType = "Bug";
        issueResolution = "Fixed";
        issueStatus = "Closed";
        issueFixVersion = tempIssueFixVersion;
        createdAfter = "";
      }
      // New features
      if (i == 1) {
        issueType = "\"New Feature\", Task, Improvement, Sub-task";
        issueResolution = "Fixed";
        issueStatus = "Closed";
        issueFixVersion = tempIssueFixVersion;
        createdAfter = "";
      }

      // Known issues
      if (i == 2) {
        issueType = "Bug";
        issueResolution = "Unresolved";
        issueStatus = "";
        issueFixVersion = "";
        createdAfter = tempCreatedAfter;
      }

      String jqlQuery =
          jiraClient.createJqlQuery(
              issueProject,
              issueType,
              issueResolution,
              issueStatus,
              issueFixVersion,
              sprintNumber,
              createdAfter);
      System.out.println("query: " + jqlQuery);
      SearchResult filter = jiraClient.createFilter(jqlQuery);
      Set<Issue> issuesFromFilter = jiraClient.getIssuesFromFilter(filter);

      for (Issue issue : issuesFromFilter) {
        String fieldsText;
        String newEntryText;
        if (!jiraClient.isPublicIssue(mapper, issue)) {
          continue;
        }
        if (issueType.contains("Bug")) {
          if (issueResolution.contains("Unresolved")) {
            fieldsText =
                "{card:label=Known Issues & Limitations}\n"
                    + "|| Key || Summary || SalesForce ID || Since version || Workaround || Platform/s ||";
            newEntryText =
                "| "
                    + issue.getKey()
                    + " | "
                    + issue.getSummary()
                    + " | "
                    + jiraClient.salesforceIdIterableToToString(issue)
                    + " | "
                    + sinceVersion
                    + " | | "
                    + jiraClient.platformsIterableToToString(mapper, issue)
                    + " |";
          } else {
            fieldsText =
                "{card:label=Fixed Issues}\n"
                    + "|| Key || Summary || Fixed in Version || SalesForce ID || Platform/s ||";
            newEntryText =
                "| "
                    + issue.getKey()
                    + " | "
                    + issue.getSummary()
                    + " | "
                    + jiraClient.fixVersionIterableToToString(issue)
                    + " | "
                    + jiraClient.salesforceIdIterableToToString(issue)
                    + " | "
                    + jiraClient.platformsIterableToToString(mapper, issue)
                    + " |";
          }
        } else {
          fieldsText =
              "{card:label=New Features and Improvements}\n"
                  + "|| Key || Summary || Since Version || SalesForce ID || Documentation Link || Platform/s ||";
          newEntryText =
              "| "
                  + issue.getKey()
                  + " | "
                  + issue.getSummary()
                  + " | "
                  + jiraClient.fixVersionIterableToToString(issue)
                  + " | "
                  + jiraClient.salesforceIdIterableToToString(issue)
                  + " | | "
                  + jiraClient.platformsIterableToToString(mapper, issue)
                  + " |";
        }

        int cardStartIndex = pageContent.indexOf(fieldsText);
        String cardSubstring =
            pageContent.substring(cardStartIndex, cardStartIndex + fieldsText.length());

        String newCardSubstring;
        String newText = fieldsText + "\n" + newEntryText;
        newCardSubstring = cardSubstring.replace(fieldsText, newText);
        pageContent = pageContent.replace(cardSubstring, newCardSubstring);
        page.setContent(pageContent);
      }
    }
    wikiClient.getConfluenceSOAPService().storePage(wikiClient.getToken(), page);
  }