示例#1
0
  /**
   * チケットの作成
   *
   * @return 成功または失敗を返す (true:成功, false:失敗)
   */
  public static Boolean createTicket() {
    // チケットの取得
    RedmineManager mgr = RedmineManagerFactory.createWithApiKey(redmineHost, apiAccessKey);
    try {

      // チケットを作成する
      Issue ticket = IssueFactory.create(null);

      // プロジェクトの指定
      int intProjectKey = mgr.getProjectManager().getProjectByKey(projectKey).getId();
      Project project = ProjectFactory.create(intProjectKey);
      ticket.setProject(project);

      // チケット内容の設定
      ticket.setSubject("デプロイ成功.");
      ticket.setDescription("デプロイを実行しました。" + StringUtil.getTimestamp());

      // トラッカー指定
      Tracker tracker = TrackerFactory.create(3, "Support");
      ticket.setTracker(tracker);

      // 開始日
      ticket.setStartDate(Calendar.getInstance().getTime());

      // 期日
      ticket.setDueDate(Calendar.getInstance().getTime());

      // ステータス (new)
      ticket.setStatusId(1);

      // 開始日
      ticket.setStartDate(Calendar.getInstance().getTime());

      // 期日
      ticket.setDueDate(Calendar.getInstance().getTime());

      // 進捗率
      ticket.setDoneRatio(100);

      // 担当者 (カレントユーザ)
      User assignee = mgr.getUserManager().getCurrentUser();
      ticket.setAssignee(assignee);

      // チケットの登録処理
      IssueManager issueMgr = mgr.getIssueManager();
      Issue newIssue = issueMgr.createIssue(ticket);
      issueMgr.update(newIssue);

      // 処理結果
      System.out.println(JSON.encode(newIssue, true));
      System.out.println("success.");

      return true;

    } catch (Exception e) {
      System.out.println(e.getStackTrace());
      return false;
    }
  }
示例#2
0
 @SuppressWarnings("unused")
 private static void tryUpload(
     RedmineManager mgr, IssueManager issueManager, AttachmentManager attachmentManager)
     throws RedmineException, IOException {
   final byte[] content = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
   final Attachment attach1 =
       attachmentManager.uploadAttachment("test.bin", "application/ternary", content);
   final Issue testIssue = new Issue();
   testIssue.setSubject("This is upload ticket!");
   testIssue.addAttachment(attach1);
   final Project tmpProject = ProjectFactory.create("Upload project", "uploadtmpproject");
   final Project project = mgr.getProjectManager().createProject(tmpProject);
   try {
     final Issue createdIssue = issueManager.createIssue(project.getIdentifier(), testIssue);
     try {
       System.out.println(createdIssue.getAttachments());
     } finally {
       issueManager.deleteIssue(createdIssue.getId());
     }
   } finally {
     mgr.getProjectManager().deleteProject(project.getIdentifier());
   }
 }