diff options
author | Matt Rendina <rendinam@users.noreply.github.com> | 2019-06-28 12:51:46 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-28 12:51:46 -0400 |
commit | f6e97c1614c271093a6bc11eb4a37b4a9915cd3b (patch) | |
tree | 660c6bb079cddd7d4392ce3718beb04e3da91c9f | |
parent | 0576b7bcd04327acb3d082a71f7aaf5fef484488 (diff) | |
download | jscu_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
-rw-r--r-- | Jenkinsfile | 2 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/BuildConfig.groovy | 3 | ||||
-rw-r--r-- | vars/utils.groovy | 25 |
4 files changed, 27 insertions, 4 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index 0ebbf0f..6bd8169 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -//@Library('utils@homedir') _ +//@Library('utils@dow-filter') _ // [skip ci] and [ci skip] have no effect here. if (utils.scm_checkout(['skip_disable':true])) return @@ -114,6 +114,7 @@ It has the following properties: | --- | --- | --- | --- | | `nodetype` | string | yes | The Jenkins node label to which the build is assigned | | `name` | string | yes | A (short) arbitrary name/description of the build configuration. Builds are named `<nodetype>/<name>` in the build status GUI. I.e. "linux/stable" or "linux/debug" | +| `run_on_days` | list of strings | no | Primarily for periodic regression test (RT) job use. A list of day-of-week names on which to execute the associated BuildConfig. Example: `bc0.run_on_days = ['sat', 'sun']` to only run the BuildConfig on those two days. | | `conda_packages` | list of strings | no | If this list is defined, the associated build job will create a temporary conda environment to host the job which contains the packages specified. Package specifications are of the form <ul><li> `<package_name>` </li><li> `<package_name>=<version>` </li></ul> Example: `bc0.conda_packages = ["pytest", "requests", "numpy=1.14.3"]` | | `conda_override_channels` | boolean | no | Instructs the conda environment creation process to not implicitly prepend the anaconda defaults channel to the list of channels used. This allows the priority of channels to be used for environment creation to be specified exactly in the order of channels provided in the `conda_channels` list, described below. If `conda_packages` is not defined in the Jenkinsfile this property is ignored. | | `conda_channels` | list of strings | no | The list of channels, in order of search priority, to use when retrieving packages for installation. If `conda_override_channels` is not defined, this list will have the conda `defaults` channel implicitly prepended to it at installation time. If `conda_packages` is not defined in the Jenkinsfile this property is ignored. Example: `bc0.conda_channels = ["http://ssb.stsci.edu/astroconda"]` | diff --git a/src/BuildConfig.groovy b/src/BuildConfig.groovy index 67a97a5..9bae307 100644 --- a/src/BuildConfig.groovy +++ b/src/BuildConfig.groovy @@ -25,6 +25,9 @@ class BuildConfig implements Serializable { def skippedUnstableNewThresh = '' def skippedUnstableThresh= '' + // Scheduling + def run_on_days = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri'] + // Private. Not to be used directly by Jenkinsfile. def runtime = [] 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) } |