asfgit closed pull request #8: Trigger build bugfix
URL: https://github.com/apache/ignite-teamcity-bot/pull/8
 
 
   

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/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/util/HttpUtil.java 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/util/HttpUtil.java
index 1184869..4730606 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/util/HttpUtil.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/util/HttpUtil.java
@@ -93,8 +93,10 @@ public static InputStream sendGetToGit(String githubAuthTok, 
String url) throws
         URL obj = new URL(url);
         HttpURLConnection con = (HttpURLConnection)obj.openConnection();
 
+        if (githubAuthTok != null)
+            con.setRequestProperty("Authorization", "token " + githubAuthTok);
+
         con.setRequestProperty("accept-charset", 
StandardCharsets.UTF_8.toString());
-        con.setRequestProperty("Authorization", "token " + githubAuthTok);
         con.setRequestProperty("Connection", "Keep-Alive");
         con.setRequestProperty("Keep-Alive", "header");
 
diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuild.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuild.java
index 2148a35..9269cbe 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuild.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/rest/TriggerBuild.java
@@ -32,6 +32,7 @@
 import org.apache.ignite.ci.github.PullRequest;
 import org.apache.ignite.ci.tcmodel.result.Build;
 import org.apache.ignite.ci.user.ICredentialsProv;
+import org.apache.ignite.ci.util.XmlUtil;
 import org.apache.ignite.ci.web.CtxListener;
 import org.apache.ignite.ci.web.rest.login.ServiceUnauthorizedException;
 import org.apache.ignite.ci.web.model.SimpleResult;
@@ -56,6 +57,7 @@ public SimpleResult triggerBuild(
         @Nullable @QueryParam("top") Boolean top,
         @Nullable @QueryParam("observe") Boolean observe
     ) {
+        String errors = "";
         final ICredentialsProv prov = ICredentialsProv.get(req);
 
         if (!prov.hasAccess(srvId))
@@ -64,33 +66,37 @@ public SimpleResult triggerBuild(
         ITcHelper helper = CtxListener.getTcHelper(context);
 
         try (final ITeamcity teamcity = helper.server(srvId, prov)) {
-            PullRequest pr = teamcity.getPullRequest(branchName);
-
-            String ticketId = "";
+            Build build = teamcity.triggerBuild(suiteId, branchName, false, 
top != null && top);
 
-            if (pr.getTitle().startsWith("IGNITE-")) {
-                int beginIdx = 7;
-                int endIdx = 7;
+            if (observe != null && observe) {
+                PullRequest pr = teamcity.getPullRequest(branchName);
 
-                while (endIdx < pr.getTitle().length() && 
Character.isDigit(pr.getTitle().charAt(endIdx)))
-                    endIdx++;
+                String ticketId = "";
 
-                ticketId = pr.getTitle().substring(beginIdx, endIdx);
-            }
+                if (pr.getTitle().startsWith("IGNITE-")) {
+                    int beginIdx = 7;
+                    int endIdx = 7;
 
-            if (ticketId.equals(""))
-                return new SimpleResult("PR title \"" + pr.getTitle() + "\" 
should starts with \"IGNITE-XXXX\"." +
-                    " 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>.");
+                    while (endIdx < pr.getTitle().length() && 
Character.isDigit(pr.getTitle().charAt(endIdx)))
+                        endIdx++;
 
-            Build build = teamcity.triggerBuild(suiteId, branchName, false, 
top != null && top);
+                    ticketId = pr.getTitle().substring(beginIdx, endIdx);
+                }
 
-            if (observe != null && observe)
-                helper.buildObserver().observe(build, srvId, prov, "ignite-" + 
ticketId);
+                if (!ticketId.equals(""))
+                    helper.buildObserver().observe(build, srvId, prov, 
"ignite-" + ticketId);
+                else {
+                    errors += "<br>" +
+                        "JIRA ticket will not be notified after the tests are 
completed - " +
+                        "PR title \"" + pr.getTitle() + "\" should starts with 
\"IGNITE-XXXX\"." +
+                        " 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>.";
+                }
+            }
         }
 
-        return new SimpleResult("OK");
+        return new SimpleResult("Tests started." + errors);
     }
 
     @GET
diff --git a/ignite-tc-helper-web/src/main/webapp/index.html 
b/ignite-tc-helper-web/src/main/webapp/index.html
index fc8020b..97cfebd 100644
--- a/ignite-tc-helper-web/src/main/webapp/index.html
+++ b/ignite-tc-helper-web/src/main/webapp/index.html
@@ -157,7 +157,7 @@
     $.ajax({
         url: url,
         success: function(result) {
-            $("#runAll").html("Run All test build was started for PR #" + 
prId);
+            $("#runAll").html(result.result);
         },
         error: showErrInLoadStatus
     });


 

----------------------------------------------------------------
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

Reply via email to