Пример #1
0
 // @Test
 public void testGetIssueByJql() {
   RemoteIssue[] issueByJql = lxitJiraService.getIssueByJql("project = DL1003  AND status = Open");
   for (RemoteIssue remoteIssue : issueByJql) {
     LxitJiraService.fixIssue(remoteIssue.getKey());
     System.out.println(
         "LxitJiraIssueServiceTest.testGetIssueByJql() key:" + remoteIssue.getKey());
   }
 }
Пример #2
0
 public static void main(String[] args) {
   LxitJiraService jirairaService = new LxitJiraService();
   RemoteIssue[] issueByJql = jirairaService.getIssueByJql("project = DLSIX  AND status = Open");
   for (RemoteIssue remoteIssue : issueByJql) {
     LxitJiraService.fixIssue(remoteIssue.getKey());
     System.out.println(
         "LxitJiraIssueServiceTest.testGetIssueByJql() key:" + remoteIssue.getKey());
   }
 }
 /** {@inheritDoc} */
 @Override
 public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
     throws InterruptedException, IOException {
   JIRAClient client = null;
   // Get the previous JIRA Build Action, if any.
   Run<?, ?> prevBuild = build.getPreviousBuild();
   JIRABuildResultReportAction buildAction = null;
   if (prevBuild != null) {
     buildAction = prevBuild.getAction(JIRABuildResultReportAction.class);
   }
   try {
     client = getSite().createClient();
     if (build.getResult().isWorseThan(Result.SUCCESS)) {
       String issueKey = null;
       if (buildAction != null
           && StringUtils.isNotBlank(buildAction.raisedIssueKey)
           && !buildAction.resolved) {
         // Oke the previous build also failed and has an Issue linked to it.
         // So relink that issue also to this build
         issueKey = client.updateIssue(build, buildAction.raisedIssueKey);
       } else {
         issueKey =
             client.createIssue(build, projectKey, issueType, issuePriority, assignToBuildBreaker);
       }
       build.addAction(new JIRABuildResultReportAction(build, issueKey, false));
       listener.getLogger().println("JBRR: Raised build failure issue: " + issueKey);
     } else if (autoClose && build.getResult().isBetterOrEqualTo(Result.SUCCESS)) {
       // Auto close the previously raised issues, if any
       if (buildAction != null) {
         RemoteIssue issue = client.getIssue(buildAction);
         if (issue == null || issue.getKey() == null) {
           listener
               .getLogger()
               .println(
                   "WARN: Failed to automatically close issue: Unable to locate issue "
                       + buildAction.raisedIssueKey
                       + " in JIRA site "
                       + getSite().name);
         } else if (client.canCloseIssue(issue)) {
           if (client.closeIssue(issue, build)) {
             build.addAction(new JIRABuildResultReportAction(build, issue.getKey(), true));
             listener
                 .getLogger()
                 .println(
                     "INFO: Closed issue "
                         + issue.getKey()
                         + " using action: "
                         + getSite().getCloseActionName());
           } else {
             listener
                 .getLogger()
                 .println("WARN: Failed to automatically close issue: " + issue.getKey());
           }
         }
       }
     }
   } catch (AxisFault e) {
     listener.error("JBRR: " + e.getFaultString());
   } catch (ServiceException e) {
     listener.error("JBRR: " + e.getMessage());
   } catch (MalformedURLException e) {
     listener.error("JBRR: Invalid JIRA URL configured");
   } finally {
     if (client != null) {
       client.logout();
     }
   }
   return true;
 }