Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jfrog.hudson.util;
  
 import  org.jfrog.build.api.Issue;
 import  org.jfrog.build.api.IssueTracker;
 import  org.jfrog.build.api.Issues;
 import  org.jfrog.build.api.IssuesTrackerFields;
 import  org.jfrog.build.api.builder.BuildInfoBuilder;
 import  org.jfrog.build.client.ArtifactoryClientConfiguration;
 import  org.jfrog.build.util.IssuesTrackerUtils;
 
 import java.net.URL;
 import java.util.Set;

Author(s):
Noam Y. Tenne
 
 public class IssuesTrackerHelper {
 
     private String issueTrackerVersion;
     private boolean aggregateBuildIssues;
     private String aggregationBuildStatus;
     private String affectedIssues;
     private String matrixParams;
 
     public IssuesTrackerHelper(AbstractBuild buildBuildListener listenerboolean aggregateBuildIssues,
             String aggregationBuildStatus) {
         this. = aggregateBuildIssues;
         this. = aggregationBuildStatus;
         JiraSite site = JiraSite.get(build.getProject());
         if (site == null) {
             return;
         }
 
         try {
             JiraSession session = site.createSession();
             RemoteServerInfo info = session.service.getServerInfo(session.token);
              = info.getVersion();
             StringBuilder affectedIssuesBuilder = new StringBuilder();
             StringBuilder matrixParamsBuilder = new StringBuilder();
             Set<StringissueIds = Sets.newHashSet(manuallyCollectIssues(buildsite.getIssuePattern()));
             for (String issueId : issueIds) {
                 if (!site.existsIssue(issueId)) {
                     continue;
                 }
 
                 if (affectedIssuesBuilder.length() > 0) {
                     affectedIssuesBuilder.append(",");
                     matrixParamsBuilder.append(",");
                 }
 
                 URL url = site.getUrl(issueId);
                 JiraIssue issue = site.getIssue(issueId);
                 affectedIssuesBuilder.append(issueId).append(">>").append(url.toString()).append(">>").append(
                         issue.title);
                 matrixParamsBuilder.append(issueId);
             }
              = affectedIssuesBuilder.toString();
              = matrixParamsBuilder.toString();
         } catch (Exception e) {
             listener.getLogger()
                     .print("[Warning] Error while trying to collect issue tracker and change information: " +
                             e.getMessage());
         }
     }
 
     private Set<StringmanuallyCollectIssues(AbstractBuild buildPattern issuePattern)
         Class<?> jiraUpdaterClass = Class.forName("hudson.plugins.jira.Updater");
         Method findIssueIdsRecursive = jiraUpdaterClass.getDeclaredMethod("findIssueIdsRecursive"AbstractBuild.class,
                 Pattern.classBuildListener.class);
         findIssueIdsRecursive.setAccessible(true);
         return (Set<String>) findIssueIdsRecursive.invoke(nullbuildissuePattern,
                 new StreamBuildListener(new NullOutputStream()));
     }

    
Applying issues tracker info to a client configuration (used by the extractors)
 
     public void setIssueTrackerInfo(ArtifactoryClientConfiguration configuration) {
         configuration.info.issues.setIssueTrackerName("JIRA");
         configuration.info.issues.setIssueTrackerVersion();
         configuration.info.issues.setAggregateBuildIssues();
         if () {
             configuration.info.issues.setAggregationBuildStatus();
         } else {
             configuration.info.issues.setAggregationBuildStatus("");
         }
        configuration.info.issues.setAffectedIssues();
        configuration.publisher.addMatrixParam(IssuesTrackerFields.AFFECTED_ISSUES, );
    }

    
Apply issues tracker info to a build info builder (used by generic tasks and maven2 which doesn't use the extractor
    public void setIssueTrackerInfo(BuildInfoBuilder builder) {
        Issues issues = new Issues();
        issues.setAggregateBuildIssues();
        issues.setAggregationBuildStatus();
        issues.setTracker(new IssueTracker("JIRA"));
        Set<Issue> affectedIssuesSet = IssuesTrackerUtils.getAffectedIssuesSet();
        if (!affectedIssuesSet.isEmpty()) {
            issues.setAffectedIssues(affectedIssuesSet);
        }
        builder.issues(issues);
    }
New to GrepCode? Check out our FAQ X