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/31 19:10:28 UTC

[ignite-teamcity-bot] branch ignite-11105-alias updated: IGNITE-11105 Support Teamcity servers aliases: host config refactoring started

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch ignite-11105-alias
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/ignite-11105-alias by this push:
     new f9965fd  IGNITE-11105 Support Teamcity servers aliases: host config refactoring started
f9965fd is described below

commit f9965fdea618435d42e663b61bc53263562013c3
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Thu Jan 31 22:10:25 2019 +0300

    IGNITE-11105 Support Teamcity servers aliases: host config refactoring started
---
 .../apache/ignite/ci/IgniteTeamcityConnection.java | 25 ++++++++++------------
 .../ci/github/ignited/IGitHubConnIgnited.java      |  5 -----
 .../ignite/ci/jira/pure/IJiraIntegration.java      |  3 ---
 .../java/org/apache/ignite/ci/jira/pure/Jira.java  | 11 +++-------
 .../ignite/ci/tcbot/conf/ITcServerConfig.java      |  3 +++
 .../ignite/ci/tcbot/conf/TcServerConfig.java       | 24 ++++++++++++++++++++-
 6 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
index b0ebdc1..05061ff 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/IgniteTeamcityConnection.java
@@ -115,15 +115,13 @@ public class IgniteTeamcityConnection implements ITeamcity {
     }
 
     /** {@inheritDoc} */
-    public void init(@Nullable String tcName) {
+    @Override public void init(@Nullable String tcName) {
         this.tcName = tcName;
 
         ITcServerConfig tcCfg = this.config.getTeamcityConfig(tcName);
         final Properties props = tcCfg.properties();
 
-        final String hostConf = props.getProperty(HelperConfig.HOST, "https://ci.ignite.apache.org/");
-
-        this.host = hostConf.trim() + (hostConf.endsWith("/") ? "" : "/");
+        this.host = tcCfg.host();
 
         try {
             if (!Strings.isNullOrEmpty(props.getProperty(HelperConfig.USERNAME))
@@ -151,7 +149,6 @@ public class IgniteTeamcityConnection implements ITeamcity {
         return basicAuthTok != null;
     }
 
-
     /** {@inheritDoc} */
     @AutoProfiling
     @Override public List<Agent> agents(boolean connected, boolean authorized) {
@@ -178,7 +175,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
 
                 return file;
             }
-            String url = host + "downloadBuildLog.html" + "?buildId=" + buildIdStr + "&archived=true";
+            String url = host() + "downloadBuildLog.html" + "?buildId=" + buildIdStr + "&archived=true";
 
             try {
                 HttpUtil.sendGetCopyToFile(basicAuthTok, url, file);
@@ -246,7 +243,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
             "    </properties>\n" +
             "</build>";
 
-        String url = host + "app/rest/buildQueue";
+        String url = host() + "app/rest/buildQueue";
 
         try {
             logger.info("Triggering build: buildTypeId={}, branchName={}, cleanRebuild={}, queueAtTop={}",
@@ -318,12 +315,12 @@ public class IgniteTeamcityConnection implements ITeamcity {
 
     /** {@inheritDoc} */
     @Override public List<Project> getProjects() {
-        return sendGetXmlParseJaxb(host + "app/rest/latest/projects", ProjectsList.class).projects();
+        return sendGetXmlParseJaxb(host() + "app/rest/latest/projects", ProjectsList.class).projects();
     }
 
     /** {@inheritDoc} */
     @Override public List<BuildType> getBuildTypes(String projectId) {
-        return sendGetXmlParseJaxb(host + "app/rest/latest/projects/" + projectId, Project.class)
+        return sendGetXmlParseJaxb(host() + "app/rest/latest/projects/" + projectId, Project.class)
             .getBuildTypesNonNull();
     }
 
@@ -352,7 +349,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
     /** {@inheritDoc} */
     @AutoProfiling
     @Override public BuildTypeFull getBuildType(String buildTypeId) {
-        return sendGetXmlParseJaxb(host + "app/rest/latest/buildTypes/id:" +
+        return sendGetXmlParseJaxb(host() + "app/rest/latest/buildTypes/id:" +
             buildTypeId, BuildTypeFull.class);
     }
 
@@ -367,7 +364,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
      * @param elem Element class.
      */
     private <T> T getJaxbUsingHref(String href, Class<T> elem) {
-        return sendGetXmlParseJaxb(host + (href.startsWith("/") ? href.substring(1) : href), elem);
+        return sendGetXmlParseJaxb(host() + (href.startsWith("/") ? href.substring(1) : href), elem);
     }
 
     /** {@inheritDoc} */
@@ -443,7 +440,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
     @Override public List<BuildRef> getBuildRefsPage(String fullUrl, AtomicReference<String> outNextPage) {
         String relPath = "app/rest/latest/builds?locator=defaultFilter:false";
         String relPathSelected = Strings.isNullOrEmpty(fullUrl) ? relPath : fullUrl;
-        String url = host + (relPathSelected.startsWith("/") ? relPathSelected.substring(1) : relPathSelected);
+        String url = host() + (relPathSelected.startsWith("/") ? relPathSelected.substring(1) : relPathSelected);
         Builds builds = sendGetXmlParseJaxb(url, Builds.class);
 
         outNextPage.set(Strings.emptyToNull(builds.nextHref()));
@@ -455,7 +452,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
     @Override public SortedSet<MuteInfo> getMutesPage(String buildTypeId, String fullUrl, AtomicReference<String> nextPage) {
         String relPath = "app/rest/mutes?locator=project:(id:" + buildTypeId + ')';
         String relPathSelected = Strings.isNullOrEmpty(fullUrl) ? relPath : fullUrl;
-        String url = host + (relPathSelected.startsWith("/") ? relPathSelected.substring(1) : relPathSelected);
+        String url = host() + (relPathSelected.startsWith("/") ? relPathSelected.substring(1) : relPathSelected);
 
         Mutes mutes = sendGetXmlParseJaxb(url, Mutes.class);
 
@@ -468,7 +465,7 @@ public class IgniteTeamcityConnection implements ITeamcity {
     @AutoProfiling
     @Override public TestOccurrencesFull getTestsPage(int buildId, @Nullable String href, boolean testDtls) {
         String relPathSelected = Strings.isNullOrEmpty(href) ? testsStartHref(buildId, testDtls) : href;
-        String url = host + (relPathSelected.startsWith("/") ? relPathSelected.substring(1) : relPathSelected);
+        String url = host() + (relPathSelected.startsWith("/") ? relPathSelected.substring(1) : relPathSelected);
         return sendGetXmlParseJaxb(url, TestOccurrencesFull.class);
     }
 
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/IGitHubConnIgnited.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/IGitHubConnIgnited.java
index 3548670..ca7b91b 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/IGitHubConnIgnited.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/github/ignited/IGitHubConnIgnited.java
@@ -16,12 +16,8 @@
  */
 package org.apache.ignite.ci.github.ignited;
 
-import com.google.common.base.Preconditions;
 import java.util.List;
-import javax.annotation.Nullable;
-import org.apache.ignite.ci.di.AutoProfiling;
 import org.apache.ignite.ci.github.PullRequest;
-import org.apache.ignite.ci.github.pure.IGitHubConnection;
 import org.apache.ignite.ci.tcbot.conf.IJiraServerConfig;
 
 /**
@@ -41,7 +37,6 @@ public interface IGitHubConnIgnited {
      *
      * @param url Url.
      * @param body Request body.
-     * @return {@code True} - if GitHub was notified. {@code False} - otherwise.
      */
     public void notifyGit(String url, String body);
 
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/IJiraIntegration.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/IJiraIntegration.java
index e5d7d7a..262f930 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/IJiraIntegration.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/IJiraIntegration.java
@@ -63,9 +63,6 @@ public interface IJiraIntegration {
      */
     public Tickets getTicketsPage(String url);
 
-    /** */
-    public String jiraUrl();
-
     /**
      * @param ticketFullName Ticket full name (e.g IGNITE-8331)
      * @return URL which is used as link to Jira ticket with specified name.
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/Jira.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/Jira.java
index d41367e..fb8d4df 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/Jira.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/jira/pure/Jira.java
@@ -75,13 +75,8 @@ class Jira implements IJiraIntegration {
     }
 
     /** {@inheritDoc} */
-    @Override public String jiraUrl() {
-        return cfg.getJiraConfig(srvId).getUrl();
-    }
-
-    /** {@inheritDoc} */
     @Override public String projectCodeForVisa() {
-        return cfg.getJiraConfig(srvId).projectCodeForVisa();
+        return config().projectCodeForVisa();
     }
 
     /** {@inheritDoc} */
@@ -106,7 +101,7 @@ class Jira implements IJiraIntegration {
 
     /** {@inheritDoc} */
     @Override public String generateTicketUrl(String ticketFullName) {
-        @Nullable String jiraUrl = jiraUrl();
+        @Nullable String jiraUrl = config().getUrl();
 
         Preconditions.checkState(!isNullOrEmpty(jiraUrl), "Jira URL is not configured for this server.");
 
@@ -143,7 +138,7 @@ class Jira implements IJiraIntegration {
 
     /** {@inheritDoc} */
     @Override @NotNull public String restApiUrl() {
-        String jiraUrl = jiraUrl();
+        String jiraUrl = config().getUrl();
 
         if (isNullOrEmpty(jiraUrl))
             throw new IllegalStateException("JIRA API URL is not configured for this server.");
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
index 17fd76e..36243fb 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/ITcServerConfig.java
@@ -22,10 +22,13 @@ import java.util.Properties;
  * Teamcity Server configuration.
  */
 public interface ITcServerConfig {
+    @Deprecated
     public Properties properties();
 
     /**
      * @return Another TC Server (service) config name to use settings from. Filled only for server aliases.
      */
     public String reference();
+
+    public String host();
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
index e7b7867..a3d4fb9 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/TcServerConfig.java
@@ -16,8 +16,11 @@
  */
 package org.apache.ignite.ci.tcbot.conf;
 
+import com.google.common.base.Strings;
 import java.util.Properties;
 import javax.annotation.Nonnull;
+import org.apache.ignite.ci.HelperConfig;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -31,7 +34,8 @@ public class TcServerConfig implements ITcServerConfig {
     @Nullable String reference;
 
     @Nullable private Properties props;
-
+    /** Host. */
+    @Nullable private String host;
 
     public TcServerConfig() {
 
@@ -59,6 +63,24 @@ public class TcServerConfig implements ITcServerConfig {
         return reference;
     }
 
+    /** {@inheritDoc} */
+    @Override public String host() {
+        final String hostConf = hostConfigured().trim();
+
+        return hostConf + (hostConf.endsWith("/") ? "" : "/");
+    }
+
+    /**
+     * Configured value for host.
+     */
+    @NotNull
+    public String hostConfigured() {
+        if (Strings.isNullOrEmpty(host))
+            return props.getProperty(HelperConfig.HOST, "https://ci.ignite.apache.org/");
+
+        return host;
+    }
+
     /**
      * @param props Properties.
      */