aboutsummaryrefslogtreecommitdiff
path: root/vars
diff options
context:
space:
mode:
authorMatt Rendina <rendinam@users.noreply.github.com>2019-06-28 12:51:46 -0400
committerGitHub <noreply@github.com>2019-06-28 12:51:46 -0400
commitf6e97c1614c271093a6bc11eb4a37b4a9915cd3b (patch)
tree660c6bb079cddd7d4392ce3718beb04e3da91c9f /vars
parent0576b7bcd04327acb3d082a71f7aaf5fef484488 (diff)
downloadjscu_refactor-f6e97c1614c271093a6bc11eb4a37b4a9915cd3b.tar.gz
Allow filtering of BuildConfigs based on day-of-week specification. (#57)
* Filter out BuildConfigs based on day-of-week specification. * Support human-friendly day names * Perform day-of-week filtering on BuildConfigs only. * Update docs
Diffstat (limited to 'vars')
-rw-r--r--vars/utils.groovy25
1 files changed, 22 insertions, 3 deletions
diff --git a/vars/utils.groovy b/vars/utils.groovy
index b7e2d3e..d636d1c 100644
--- a/vars/utils.groovy
+++ b/vars/utils.groovy
@@ -4,6 +4,8 @@ import groovy.io.FileType
import groovy.json.JsonOutput
import org.apache.commons.lang3.SerializationUtils
import org.apache.commons.io.FilenameUtils
+import java.util.Calendar
+import java.text.SimpleDateFormat
import org.kohsuke.github.GitHub
@@ -257,8 +259,6 @@ upload_spec = """
// @param jobconfig JobConfig object
def testSummaryNotify(jobconfig, buildconfigs, test_info) {
- //def test_info = parseTestReports(buildconfigs)
-
// If there were any test errors or failures, send the summary to github.
if (test_info.problems) {
// Match digits between '/' chars at end of BUILD_URL (build number).
@@ -721,10 +721,29 @@ def run(configs, concurrent = true) {
// Separate jobconfig from buildconfig(s).
configs.eachWithIndex { config ->
- // Extract a JobConfig object if one is found.
+ dowMap = ["sun":1, "mon":2, "tue":3, "wed":4, "thu":5, "fri":6, "sat":7]
+ def date = new Date()
+ Calendar c = Calendar.getInstance()
+ c.setTime(date)
+ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK)
+
+
+ // Extract a JobConfig object if one is found
if (config.getClass() == JobConfig) {
jobconfig = config // TODO: Try clone here to make a new instance
return // effectively a 'continue' from within a closure.
+ }
+
+ days = []
+ for (day in config.run_on_days) {
+ days.add(dowMap[day.toLowerCase()])
+ }
+
+ // Remove any JobConfig with a day-of-week request that does not match
+ // today.
+ if (!(dayOfWeek in days)) {
+ println("Skipping build of [${config.name}] due to 'run_on_days' stipulation.")
+ return
} else {
buildconfigs.add(config)
}