SomeFire closed pull request #103: support configurable prefix for Jira ticket names URL: https://github.com/apache/ignite-teamcity-bot/pull/103
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/conf/apache.auth.properties b/conf/apache.auth.properties index a022bf70..a45cfae7 100644 --- a/conf/apache.auth.properties +++ b/conf/apache.auth.properties @@ -6,6 +6,7 @@ git.api_url=https://api.github.com/repos/apache/ignite/ jira.api_url=https://issues.apache.org/jira/rest/api/2/ jira.url=https://issues.apache.org/jira/ +jira.ticket_template="IGNITE-" #specify JIRA Auth token (if needed) jira.auth_token= diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java index 50207d83..dc089581 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/HelperConfig.java @@ -63,6 +63,9 @@ /** JIRA URL to build links to tickets. */ public static final String JIRA_URL = "jira.url"; + /** Template for JIRA ticket names. */ + public static final String JIRA_TICKET_TEMPLATE = "jira.ticket_template"; + /** Slack authorization token property name. */ public static final String SLACK_AUTH_TOKEN = "slack.auth_token"; public static final String SLACK_CHANNEL = "slack.channel"; diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/IJiraIntegration.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/IJiraIntegration.java index 12b3836a..7e9caa37 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/IJiraIntegration.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/IJiraIntegration.java @@ -55,6 +55,9 @@ public Visa notifyJira(String srvId, ICredentialsProv prov, String buildTypeId, /** */ public String jiraUrl(); + /** */ + public String ticketTemplate(); + /** */ public void init(String srvId); diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Jira.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Jira.java index 8755b90c..4ce05307 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Jira.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Jira.java @@ -38,6 +38,9 @@ /** */ private String jiraUrl; + /** */ + private String jiraTicketTemplate; + /** {@inheritDoc} */ @Override public void init(String srvId) { final File workDir = HelperConfig.resolveWorkDir(); @@ -47,6 +50,7 @@ final Properties props = HelperConfig.loadAuthProperties(workDir, cfgName); jiraUrl = props.getProperty(HelperConfig.JIRA_URL); + jiraTicketTemplate = props.getProperty(HelperConfig.JIRA_TICKET_TEMPLATE, ""); } /** {@inheritDoc} */ @@ -54,6 +58,11 @@ return jiraUrl; } + /** {@inheritDoc} */ + @Override public String ticketTemplate() { + return jiraTicketTemplate; + } + /** {@inheritDoc} */ @Override public Visa notifyJira(String srvId, ICredentialsProv prov, String buildTypeId, String branchForTc, String ticket) { diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Ticket.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Ticket.java index 6b2d49f7..5160471e 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Ticket.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/Ticket.java @@ -32,11 +32,11 @@ public Fields fields; /** + * @param ticketTemplate Ticket name template. * @return Ignite id (like 123 in IGNITE-123). */ - public int igniteId() { - //todo support non ignite/configurable prefix/string ID from compactor; - return Integer.valueOf(key.substring("IGNITE-".length())); + public int igniteId(String ticketTemplate) { + return Integer.valueOf(key.substring(ticketTemplate.length())); } /** diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketDao.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketDao.java index 4a6e4142..ee3bb30b 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketDao.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketDao.java @@ -91,9 +91,10 @@ public static long ticketToCacheKey(int srvIdMaskHigh, int igniteId) { * * @param srvIdMaskHigh Server id mask high. * @param chunk Chunk. + * @param ticketTemplate Ticket name template. */ @AutoProfiling - public void saveChunk(int srvIdMaskHigh, Collection<Ticket> chunk) { + public void saveChunk(int srvIdMaskHigh, Collection<Ticket> chunk, String ticketTemplate) { Preconditions.checkNotNull(jiraCache, "init() was not called"); if (F.isEmpty(chunk)) @@ -102,8 +103,8 @@ public void saveChunk(int srvIdMaskHigh, Collection<Ticket> chunk) { HashMap<Long, TicketCompacted> compactedTickets = new HashMap<>(U.capacity(chunk.size())); for (Ticket ticket : chunk) { - long key = ticketToCacheKey(srvIdMaskHigh, ticket.igniteId()); - TicketCompacted val = new TicketCompacted(ticket, compactor); + long key = ticketToCacheKey(srvIdMaskHigh, ticket.igniteId(ticketTemplate)); + TicketCompacted val = new TicketCompacted(ticket, compactor, ticketTemplate); compactedTickets.put(key, val); } diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketSync.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketSync.java index c5dabbcc..a5b5f3cd 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketSync.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/JiraTicketSync.java @@ -69,7 +69,7 @@ private String actualizeJiraTickets(int srvIdMaskHigh, ITeamcityConn conn, ICred if (F.isEmpty(page)) return "Something went wrong - no tickets found. Check jira availability."; - jiraDao.saveChunk(srvIdMaskHigh, page); + jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketTemplate()); int ticketsSaved = page.size(); @@ -84,7 +84,7 @@ private String actualizeJiraTickets(int srvIdMaskHigh, ITeamcityConn conn, ICred if (F.isEmpty(page)) break; - jiraDao.saveChunk(srvIdMaskHigh, page); + jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketTemplate()); ticketsSaved += page.size(); } diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/TicketCompacted.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/TicketCompacted.java index d5428be7..094ae6e0 100644 --- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/TicketCompacted.java +++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/ignited/TicketCompacted.java @@ -38,11 +38,11 @@ /** * @param ticket Jira ticket. * @param comp Compactor. + * @param ticketTemplate Ticket name template. */ - public TicketCompacted(Ticket ticket, IStringCompactor comp) { + public TicketCompacted(Ticket ticket, IStringCompactor comp, String ticketTemplate) { id = ticket.id; - //todo support non ignite/configurable prefix/string ID from compactor; - igniteId = Integer.valueOf(ticket.key.substring("IGNITE-".length())); + igniteId = Integer.valueOf(ticket.key.substring(ticketTemplate.length())); status = comp.getStringId(ticket.fields.status.name); } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services