Ejemplo n.º 1
0
        public void executeJob()
        {
            String status = Messenger.Instance.getStatus();

            if (status.Contains("Online") && config.activeMessaging && isWorkToday())
            {
                if (config.bldStatusChanged || config.bldFroze || config.eachBuildStatus)
                {
                    BuildConnector lastBuild = new BuildConnector(config.url, true);
                    if (lastBuild.isValid())
                    {
                        BuildConnector finishedBuild;
                        Trace.WriteLine(String.Format("\\\\ Checking {0} #{1} with actual status: {2} and previous status {3}",
                                config.name, lastBuild.getNumber(), lastBuild.getStatus().ToUpper(), config.lastBuildStatus.ToUpper()));

                        if (config.bldFroze) buildFrozen(lastBuild);

                        if (lastBuild.getStatus() == BuildConnector.activeBuild)
                        {
                            int prevBildNumber = lastBuild.getNumber() - 1;
                            finishedBuild = new BuildConnector(config.url, prevBildNumber);
                        }
                        else
                        {
                            finishedBuild = lastBuild;
                        }
                        if (finishedBuild.isValid())
                        {
                            if (config.bldStatusChanged) buildStatusCnahged(finishedBuild);
                            if (config.eachBuildStatus) eachBuildStatus(finishedBuild);
                            if (config.bldStillRed) buildStillRed(finishedBuild);

                            updateConfig(finishedBuild);
                        }
                    }
                }

                if (config.dailyReport) dailyReport();
                if (config.grpStatusMonitoring) groupStatusMonitoring();
            }

            if (!String.IsNullOrEmpty(updateConfigStatus) && status.Contains(updateConfigStatus))
            {
                TaskLauncher.closeThreads();
                Messenger.Instance.goOnline();
            }
        }
Ejemplo n.º 2
0
        private void buildStatusCnahged(BuildConnector build)
        {
            if (!config.lastBuildStatus.Contains(build.getStatus()) && config.lastBuildNumber < build.getNumber())
            {
                BuildStatusMonitor monitor = new BuildStatusMonitor(build);
                monitor.prepareData(config.bldStatusChangedConfigs);
                if (monitor.isValid())
                {
                    if (config.buildStatusTopicChange)
                    {
                        String newTopic = monitor.getTopic();
                        String actualTopic = Messenger.Instance.getTopicName(config.messengerChatId);
                        if (!String.IsNullOrEmpty(newTopic) && newTopic != actualTopic)
                        {
                            newTopic = "/topic " + newTopic;
                            Messenger.Instance.sendMessage(config.messengerChatId, newTopic);
                        }
                    }

                    String messageText = monitor.getMessage();
                    if (!String.IsNullOrEmpty(messageText))
                        Messenger.Instance.sendMessage(config.messengerChatId, messageText);
                }
            }
        }
Ejemplo n.º 3
0
 private void updateConfig(BuildConnector build)
 {
     if(build.getNumber() != config.lastBuildNumber)
     {
         if (!BuildConnector.abortedPattern.Contains(build.getStatus()))
             Config.Instance.Find(x => x.name == config.name).lastBuildStatus = getStatusPattern(build.getStatus());
         Config.Instance.Find(x => x.name == config.name).lastBuildNumber = build.getNumber();
         Config.Instance.Find(x => x.name == config.name).lastFinishTime = build.getTimestamp() + build.getDuraction();
     }
 }
Ejemplo n.º 4
0
 private void buildFrozen(BuildConnector build)
 {
     if (build.getStatus() == BuildConnector.activeBuild)
     {
         long workingTime = TimeUtils.timestampToSeconds(TimeUtils.getTimestamp() - build.getTimestamp());
         if (workingTime > config.bldFrozenTimeout && build.getNumber() != config.lastFrozenBuild)
         {
             workingTime = workingTime / 60;
             Messenger.Instance.sendMessage(config.messengerChatId,
                 String.Format(config.bldFrozenMessage, build.getNumber(), workingTime));
             Config.Instance.Find(x => x.name == config.name).lastFrozenBuild = build.getNumber();
         }
     }
 }