コード例 #1
0
  @Override
  public JiraClient newJiraClient() {
    Config.PluginDescriptor config = Config.getGlobalConfig();
    String jiraUrl = config.getJiraBaseUrl();
    String username = config.getUsername();
    String password = config.getPassword();

    BasicCredentials creds = new BasicCredentials(username, password);
    JiraClient client = new JiraClient(jiraUrl, creds);

    return client;
  }
コード例 #2
0
  /**
   * Parse Jira ticket numbers, ie SSD-101, out of the given ChangeLogSet.Entry.
   *
   * <p>Ticket number should be somewhere in the commit message
   *
   * @param change
   * @return
   */
  @Override
  public List<JiraCommit> getJiraIssuesFromChangeSet(final ChangeLogSet.Entry change) {
    final List<JiraCommit> result = new ArrayList<>();
    final List<String> foundTickets = new ArrayList<>();

    for (String validJiraPrefix : Config.getGlobalConfig().getJiraTickets()) {
      String msg = change.getMsg();

      while (StringUtils.isNotEmpty(msg)) {
        final int foundPos = StringUtils.indexOf(msg, validJiraPrefix);

        if (foundPos == -1) {
          break;
        }

        final String firstOccurrence = msg.substring(foundPos + validJiraPrefix.length());
        final String regex = "^([0-9]*).*$";
        final Pattern pattern = Pattern.compile(regex);
        final Matcher matcher = pattern.matcher(firstOccurrence);
        matcher.matches();

        final String ticketNumber = matcher.group(1);

        if (StringUtils.isEmpty(ticketNumber)) {
          break;
        }

        final String resultingTicket = validJiraPrefix + ticketNumber;

        if (!foundTickets.contains(resultingTicket)) {
          foundTickets.add(resultingTicket);
          result.add(new JiraCommit(resultingTicket, change));
        }

        msg = firstOccurrence;
      }
    }

    return result;
  }
コード例 #3
0
 /** TODO DOCUMENT ME! */
 @Before
 public void setUp() {
   Config.getGlobalConfig().setPattern("FOO-,BAR-");
 }