Skip to content
Permalink
Browse files
Small refactoring
  • Loading branch information
dspavlov committed Nov 17, 2021
1 parent e6a5ca9 commit ef2f08070b4efb299a1caf43162f957ac22486bb
Showing 2 changed files with 9 additions and 11 deletions.
@@ -19,9 +19,9 @@
"logsDir": "apache_logs",
/** Default tracked branch name in internal identification of TC bot. */
"defaultTrackedBranch": "master",
/** Time as auto-triggering build is disabled. ISO time formatting must be used. */
/** Time as auto-triggering build is disabled. ISO time formatting must be used, e.g. 09:00:00. Should be set simultaneusly with autoTriggeringBuildDisabledEndTime. */
// "autoTriggeringBuildDisabledStartTime": "07:00:00",
/** Time as auto-triggering build is enabled. ISO time formatting must be used. */
/** Time as auto-triggering build is enabled. ISO time formatting must be used, e.g. 18:00:00. Should be set simultaneusly with autoTriggeringBuildDisabledStartTime. */
// "autoTriggeringBuildDisabledEndTime": "20:00:00",

/** Build parameters, which may be used for filtering Run history and tagging builds. */
@@ -36,6 +36,7 @@
import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildCompacted;
import org.apache.ignite.ci.user.ITcBotUserCreds;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.tcbot.common.conf.ITcServerConfig;
import org.apache.ignite.tcbot.common.exeption.ExceptionUtil;
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.tcbot.common.interceptor.MonitoredTask;
@@ -135,7 +136,7 @@ public void init(ITcBotUserCreds creds) {
protected String runEx() {
logger.info("Build triggering task is started");

if (Boolean.valueOf(System.getProperty(AUTO_TRIGGERING_BUILD_DISABLED))) {
if (Boolean.parseBoolean(System.getProperty(AUTO_TRIGGERING_BUILD_DISABLED))) {
final String msg = "Automatic build triggering was disabled.";
logger.info(msg);
return msg;
@@ -400,27 +401,24 @@ private Map<String, List<ITrackedChain>> mapChainsByServer(Stream<ITrackedBranch

/**
* @param srvCode Server code.
* @return {@code true} if auto-triggering disabled for working hours.
* @return {@code true} if auto-triggering is disabled now for working hours.
*/
private boolean autoTriggerDisabledForWorkingHours(String srvCode) {

DayOfWeek curDayOfWeek = LocalDate.now().getDayOfWeek();

if (curDayOfWeek == DayOfWeek.SATURDAY || curDayOfWeek == DayOfWeek.SUNDAY)
return false;

String startTime = cfg.getTeamcityConfig(srvCode).autoTriggeringBuildDisabledStartTime();
ITcServerConfig tcCfg = cfg.getTeamcityConfig(srvCode);

String endTime = cfg.getTeamcityConfig(srvCode).autoTriggeringBuildDisabledEndTime();
String startTime = tcCfg.autoTriggeringBuildDisabledStartTime();
String endTime = tcCfg.autoTriggeringBuildDisabledEndTime();

if (startTime == null || endTime == null)
return false;

LocalTime now = LocalTime.now();

if (now.isAfter(LocalTime.parse(startTime)) && now.isBefore(LocalTime.parse(endTime)))
return true;

return false;
return now.isAfter(LocalTime.parse(startTime)) && now.isBefore(LocalTime.parse(endTime));
}
}

0 comments on commit ef2f080

Please sign in to comment.