[GitHub] SomeFire commented on a change in pull request #40: IGNITE-9939 BuildObserver UNKNOWN build state handling added

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] SomeFire commented on a change in pull request #40: IGNITE-9939 BuildObserver UNKNOWN build state handling added

GitBox
SomeFire commented on a change in pull request #40: IGNITE-9939 BuildObserver UNKNOWN build state handling added
URL: https://github.com/apache/ignite-teamcity-bot/pull/40#discussion_r229307325
 
 

 ##########
 File path: ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
 ##########
 @@ -69,11 +75,60 @@
     /** Helper. */
     @Inject ITcHelper tcHelper;
 
+    /** */
+    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
     /** */
     public void startObserver() {
         buildObserverProvider.get();
     }
 
+    /** */
+    public List<VisaStatus> getVisasStatus(String srvId, ICredentialsProv prov) {
+        List<VisaStatus> visaStatuses = new ArrayList<>();
+
+        IAnalyticsEnabledTeamcity teamcity = tcHelper.server(srvId, prov);
+
+        for (VisaRequest visaRequest : tcHelper.getVisasHistoryStorage().getVisas()) {
+            VisaStatus visaStatus = new VisaStatus();
+
+            BuildsInfo info = visaRequest.getInfo();
+
+            Visa visa = visaRequest.getResult();
+
+            visaStatus.date = formatter.format(info.date);
+            visaStatus.branchName = info.branchName;
+            visaStatus.userName = info.userName;
+            visaStatus.ticket = info.ticket;
+
+            if (info.isFinished(teamcity)) {
+                if (visa != null && visa.isSuccess()) {
+                    visaStatus.commentUrl = "https://issues.apache.org/jira/browse/" + visaStatus.ticket +
+                        "?focusedCommentId=" + visa.getJiraCommentResponse().getId() +
+                        "&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-" +
+                        visa.getJiraCommentResponse().getId();
+
+                    visaStatus.blockers = visa.getSuitesStatuses().stream().mapToInt(suite ->
+                        suite.testFailures.size()).sum();
+
+                    visaStatus.state = BuildsInfo.FINISHED_STATE;
+                }
+                else if (visa != null && !visa.isSuccess())
+                    visaStatus.state = BuildsInfo.FINISHED_WITH_FAILURES_STATE;
+
 
 Review comment:
   Remove empty line.

----------------------------------------------------------------
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:
[hidden email]


With regards,
Apache Git Services