You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/01/10 17:16:37 UTC
[ignite-teamcity-bot] branch ignite-gg-14609 updated:
IGNITE-GG-14609: Ticket prefix detection implemented for configurable
prefix
This is an automated email from the ASF dual-hosted git repository.
dpavlov pushed a commit to branch ignite-gg-14609
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
The following commit(s) were added to refs/heads/ignite-gg-14609 by this push:
new 3faff09 IGNITE-GG-14609: Ticket prefix detection implemented for configurable prefix
3faff09 is described below
commit 3faff09b553a6f2239582ad36da406d1df563987
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Jan 10 20:16:33 2019 +0300
IGNITE-GG-14609: Ticket prefix detection implemented for configurable prefix
---
.../java/org/apache/ignite/ci/HelperConfig.java | 2 +-
.../apache/ignite/ci/jira/IJiraIntegration.java | 5 +-
.../main/java/org/apache/ignite/ci/jira/Jira.java | 13 ++---
.../ignite/ci/jira/ignited/JiraTicketSync.java | 4 +-
.../tcbot/visa/TcBotTriggerAndSignOffService.java | 60 +++++++++++++---------
.../model/current/ChainAtServerCurrentStatus.java | 2 +-
.../ignite/ci/web/rest/visa/TcBotVisaService.java | 1 -
ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js | 13 +++--
ignite-tc-helper-web/src/main/webapp/prs.html | 5 +-
9 files changed, 56 insertions(+), 49 deletions(-)
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 dc08958..f773100 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,7 +63,7 @@ public class HelperConfig {
/** JIRA URL to build links to tickets. */
public static final String JIRA_URL = "jira.url";
- /** Template for JIRA ticket names. */
+ /** Prefix for JIRA ticket names. */
public static final String JIRA_TICKET_TEMPLATE = "jira.ticket_template";
/** Slack authorization token property name. */
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 7e9caa3..c66a736 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
@@ -19,6 +19,7 @@ package org.apache.ignite.ci.jira;
import org.apache.ignite.ci.web.model.Visa;
import org.apache.ignite.ci.user.ICredentialsProv;
+import org.jetbrains.annotations.NotNull;
/**
* Reperesents methods to provide interaction with Jira servers.
@@ -55,8 +56,8 @@ public interface IJiraIntegration {
/** */
public String jiraUrl();
- /** */
- public String ticketTemplate();
+ /** @return JIRA ticket prefix. */
+ @NotNull public String ticketPrefix();
/** */
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 aff3e46..b413193 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
@@ -25,6 +25,7 @@ import org.apache.ignite.ci.HelperConfig;
import org.apache.ignite.ci.ITcHelper;
import org.apache.ignite.ci.user.ICredentialsProv;
import org.apache.ignite.ci.web.model.Visa;
+import org.jetbrains.annotations.NotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
@@ -38,8 +39,8 @@ public class Jira implements IJiraIntegration {
/** */
private String jiraUrl;
- /** */
- private String jiraTicketTemplate;
+ /** JIRA ticket prefix. */
+ @NotNull private String jiraTicketPrefix;
/** {@inheritDoc} */
@Override public void init(String srvId) {
@@ -50,8 +51,8 @@ public class Jira implements IJiraIntegration {
final Properties props = HelperConfig.loadAuthProperties(workDir, cfgName);
jiraUrl = props.getProperty(HelperConfig.JIRA_URL);
- jiraTicketTemplate = props.getProperty(HelperConfig.JIRA_TICKET_TEMPLATE,
- "IGNITE-");
+
+ jiraTicketPrefix = props.getProperty(HelperConfig.JIRA_TICKET_TEMPLATE, "IGNITE-");
}
/** {@inheritDoc} */
@@ -60,8 +61,8 @@ public class Jira implements IJiraIntegration {
}
/** {@inheritDoc} */
- @Override public String ticketTemplate() {
- return jiraTicketTemplate;
+ @Override public String ticketPrefix() {
+ return jiraTicketPrefix;
}
/** {@inheritDoc} */
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 a5b5f3c..b7fbfd7 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 @@ public class JiraTicketSync {
if (F.isEmpty(page))
return "Something went wrong - no tickets found. Check jira availability.";
- jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketTemplate());
+ jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketPrefix());
int ticketsSaved = page.size();
@@ -84,7 +84,7 @@ public class JiraTicketSync {
if (F.isEmpty(page))
break;
- jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketTemplate());
+ jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketPrefix());
ticketsSaved += page.size();
}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
index 29a087e..1323b2c 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
@@ -193,17 +193,28 @@ public class TcBotTriggerAndSignOffService {
* @param pr Pull Request.
* @return JIRA ticket full name or empty string.
*/
+ @Deprecated
@NotNull public static String getTicketFullName(PullRequest pr) {
- String ticketId = "";
+ String prefix = "IGNITE-";
- if (pr.getTitle().toUpperCase().startsWith("IGNITE-")) {
- int beginIdx = 7;
- int endIdx = 7;
+ return getTicketFullName(pr, prefix);
+ }
+
+ /**
+ * @param pr Pull Request.
+ * @param prefix Ticket prefix.
+ * @return JIRA ticket full name or empty string.
+ */
+ @NotNull public static String getTicketFullName(PullRequest pr, @NotNull String prefix) {
+ String ticketId = "";
+ if (pr.getTitle().toUpperCase().startsWith(prefix)) {
+ int beginIdx = prefix.length();
+ int endIdx = prefix.length();
while (endIdx < pr.getTitle().length() && Character.isDigit(pr.getTitle().charAt(endIdx)))
endIdx++;
- ticketId = "IGNITE-" + pr.getTitle().substring(beginIdx, endIdx);
+ ticketId = prefix + pr.getTitle().substring(beginIdx, endIdx);
}
return ticketId;
@@ -251,17 +262,21 @@ public class TcBotTriggerAndSignOffService {
String parentSuiteId,
Build... builds
) {
+ IJiraIntegration jiraIntegration = jiraIntegrationProvider.server(srvId);
+
+ String prefix = jiraIntegration.ticketPrefix();
+
if (F.isEmpty(ticketFullName)) {
try {
IGitHubConnection gitHubConn = gitHubConnProvider.server(srvId);
PullRequest pr = gitHubConn.getPullRequest(branchForTc);
- ticketFullName = getTicketFullName(pr);
+ ticketFullName = getTicketFullName(pr, prefix);
if (ticketFullName.isEmpty()) {
return "JIRA ticket will not be notified after the tests are completed - " +
- "PR title \"" + pr.getTitle() + "\" should starts with \"IGNITE-XXXX\"." +
+ "PR title \"" + pr.getTitle() + "\" should starts with \"" + prefix + "-NNNNN\"." +
" Please, rename PR according to the" +
" <a href='https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute" +
"#HowtoContribute-1.CreateGitHubpull-request'>contributing guide</a>.";
@@ -273,8 +288,8 @@ public class TcBotTriggerAndSignOffService {
e.getMessage() + ']';
}
} else {
- //todo remove once every ticket is with IGnite prefix
- ticketFullName = ticketFullName.toUpperCase().startsWith("IGNITE-") ? ticketFullName : "IGNITE-" + ticketFullName;
+ //todo remove once every ticket is with Ignite prefix
+ ticketFullName = ticketFullName.toUpperCase().startsWith(prefix) ? ticketFullName : prefix + ticketFullName;
}
buildObserverProvider.get().observe(srvId, prov, ticketFullName, branchForTc, parentSuiteId, builds);
@@ -282,8 +297,7 @@ public class TcBotTriggerAndSignOffService {
if (!tcHelper.isServerAuthorized())
return "Ask server administrator to authorize the Bot to enable JIRA notifications.";
- return "JIRA ticket IGNITE-" + ticketFullName +
- " will be notified after the tests are completed.";
+ return "JIRA ticket " + ticketFullName + " will be notified after the tests are completed.";
}
/**
@@ -302,16 +316,20 @@ public class TcBotTriggerAndSignOffService {
ICredentialsProv prov) {
String jiraRes = "";
+ IJiraIntegration jiraIntegration = jiraIntegrationProvider.server(srvId);
+
+ String prefix = jiraIntegration.ticketPrefix();
+
if (Strings.isNullOrEmpty(ticketFullName)) {
try {
IGitHubConnection gitHubConn = gitHubConnProvider.server(srvId);
PullRequest pr = gitHubConn.getPullRequest(branchForTc);
- ticketFullName = getTicketFullName(pr);
+ ticketFullName = getTicketFullName(pr, prefix);
if (ticketFullName.isEmpty()) {
jiraRes = "JIRA ticket can't be commented - " +
- "PR title \"" + pr.getTitle() + "\" should starts with \"IGNITE-XXXX\"." +
+ "PR title \"" + pr.getTitle() + "\" should starts with \"" + prefix + "NNNNN\"." +
" Please, rename PR according to the" +
" <a href='https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute" +
"#HowtoContribute-1.CreateGitHubpull-request'>contributing guide</a>" +
@@ -323,7 +341,7 @@ public class TcBotTriggerAndSignOffService {
}
} else {
//todo remove once every ticket is with IGnite prefix
- ticketFullName = ticketFullName.toUpperCase().startsWith("IGNITE-") ? ticketFullName : "IGNITE-" + ticketFullName;
+ ticketFullName = ticketFullName.toUpperCase().startsWith(prefix) ? ticketFullName : prefix + ticketFullName;
}
if (!Strings.isNullOrEmpty(ticketFullName)) {
@@ -336,12 +354,10 @@ public class TcBotTriggerAndSignOffService {
" \"Re-run possible blockers & Comment JIRA\" was triggered for current branch." +
" Wait for the end or cancel exsiting observing.");
- IJiraIntegration jiraIntegration = jiraIntegrationProvider.server(srvId);
Visa visa = jiraIntegration.notifyJira(srvId, prov, suiteId, branchForTc, ticketFullName);
- visasHistoryStorage.put(new VisaRequest(buildsInfo)
- .setResult(visa));
+ visasHistoryStorage.put(new VisaRequest(buildsInfo).setResult(visa));
return new SimpleResult(visa.status);
}
@@ -372,7 +388,8 @@ public class TcBotTriggerAndSignOffService {
check.prAuthorAvatarUrl = user.avatarUrl();
}
- check.jiraIssueId = Strings.emptyToNull(getTicketFullName(pr));
+ String prefix = jiraIntegration.ticketPrefix();
+ check.jiraIssueId = Strings.emptyToNull(getTicketFullName(pr, prefix));
if (!Strings.isNullOrEmpty(check.jiraIssueId))
check.jiraIssueUrl = jiraIntegration.generateTicketUrl(check.jiraIssueId);
@@ -405,13 +422,6 @@ public class TcBotTriggerAndSignOffService {
if (!buildHist.isEmpty())
return buildHist;
-
- ref = ref.toLowerCase();
-
- buildHist = srv.getAllBuildsCompacted(suiteId, ref);
-
- if (!buildHist.isEmpty())
- return buildHist;
}
}
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/ChainAtServerCurrentStatus.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/ChainAtServerCurrentStatus.java
index 82ee4ec..b1d10ff 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/ChainAtServerCurrentStatus.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/current/ChainAtServerCurrentStatus.java
@@ -141,7 +141,7 @@ public class ChainAtServerCurrentStatus {
if (pullReq != null && pullReq.getTitle() != null) {
prUrl = pullReq.htmlUrl();
- ticketFullName = TcBotTriggerAndSignOffService.getTicketFullName(pullReq);
+ ticketFullName = TcBotTriggerAndSignOffService.getTicketFullName(pullReq, jiraIntegration.ticketPrefix());
if (!ticketFullName.isEmpty())
ticketUrl = jiraIntegration.generateTicketUrl(ticketFullName);
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java
index adf2c7b..131c955 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/visa/TcBotVisaService.java
@@ -89,7 +89,6 @@ public class TcBotVisaService {
@GET
@Path("contributionStatus")
public Set<ContributionCheckStatus> contributionStatus(@Nullable @QueryParam("serverId") String srvId,
- @Nonnull @QueryParam("suiteId") String suiteId,
@QueryParam("prId") String prId) {
ICredentialsProv prov = ICredentialsProv.get(req);
if (!prov.hasAccess(srvId))
diff --git a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
index ada8a87..3cbb114 100644
--- a/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
+++ b/ignite-tc-helper-web/src/main/webapp/js/prs-1.0.js
@@ -1,4 +1,4 @@
-function drawTable(srvId, suiteId, element) {
+function drawTable(srvId, element) {
let tableId = "serverContributions-" + srvId;
element.append("<div id='expandAllButton' align='right' style='margin-right:50px'></div><br>" +
@@ -19,19 +19,19 @@ function drawTable(srvId, suiteId, element) {
function requestTableForServer(srvId, suiteId, element) {
// TODO multiple servers
- if (srvId != "apache")
- return;
+ // if (srvId != "apache")
+ // return;
// TODO multiple suites
- if (suiteId != "IgniteTests24Java8_RunAll")
- return;
+ // if (suiteId != "IgniteTests24Java8_RunAll")
+ // return;
let tableId = "serverContributions-" + srvId;
if ($("#" + tableId).length > 0)
return;
- drawTable(srvId, suiteId, element);
+ drawTable(srvId, element);
$.ajax({
url: "rest/visa/contributions?serverId=" + srvId,
@@ -280,7 +280,6 @@ function formatContributionDetails(row, srvId, suiteId) {
$.ajax({
url: "rest/visa/contributionStatus" +
"?serverId=" + srvId +
- "&suiteId=" + suiteId +
"&prId=" + prId,
success:
function (result) {
diff --git a/ignite-tc-helper-web/src/main/webapp/prs.html b/ignite-tc-helper-web/src/main/webapp/prs.html
index fb5fdc6..6e72d8f 100644
--- a/ignite-tc-helper-web/src/main/webapp/prs.html
+++ b/ignite-tc-helper-web/src/main/webapp/prs.html
@@ -76,14 +76,11 @@
});
}
-
-
function prShowHref(srvId, suiteId, branchName) {
return "/pr.html?serverId=" + srvId + "&" +
"suiteId=" + suiteId +
//"&baseBranchForTc=" +
- "&branchForTc=" +
- branchName +
+ "&branchForTc=" + branchName +
"&action=Latest";
}