diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2019-03-20 16:39:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-20 16:39:13 -0400 |
commit | fd66dd6dcd026ff3cc0651bd3f5e83e3f1f84e8c (patch) | |
tree | c531e6fb377bbb4fb424e928161a82af8f37f8b0 | |
parent | 9428317aef119d4c97d8224eeea6077d35bb0530 (diff) | |
download | jscu_refactor-fd66dd6dcd026ff3cc0651bd3f5e83e3f1f84e8c.tar.gz |
Convert specifiers (#38)
* Add convert_specifiers
* Add convert_specifiers to README
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | vars/utils.groovy | 18 |
2 files changed, 20 insertions, 1 deletions
@@ -79,7 +79,8 @@ The `utils` library provides several functions: | --- | --- | | `if (utils.scm_checkout()) return` | <ul><li> Performs the cloning of the git repository that contains the Jenkinsfile.</li><li>Handles delivery of checked-out files to all subsequent build nodes called upon via the `utils.run()` function described below so that only a single clone is required to feed all parallel builds. </li><li> When used within the full `if (utils.scm_checkout()) return` clause, it also handles aborting the build immediately after the clone if either the text `[skip ci]` of `[ci skip]` if found in the latest commit message. Note: The `if` statement is unavoidable due to how Jenkins handles script termination. </li></ul> Accepts: <ul><li>`skip_disable=true` (default is false) </li></ul> Will ignore any `[skip ci]`/`[ci skip]` directive found in the latest commit message. This is used in certain regression testing jobs that run on a schedule, the execution of which should never be skipped due to skip directives found in the commit history. | | `utils.copy()` | <ul><li> Copies the single object passed in as an argument into a new instance holding all the same attribute values. Useful to avoid duplication of parameters when configurations are similar to one another. </li></ul> Accepts: <ul><li> a single `BuildConfig` object </ul></li> | -| `utils.run(config_list, concurrent=true)` | <ul><li> Responsible for running build tasks on separately provisioned hosts based on a list of configuration objects passed. </li><li> Parallel builds show up in the Jenkins (Blueocean) interface under the 'Matrix' heading. </li><li> Serial builds show up in the Jenkins (Blueocean) interface under 'Serial-#' headings. </li></ul> Accepts: <ul><li> a single list of BuildConfig objects </li><li> (optional) A boolean named `concurrent` Default is `true`. When 'false', each `BuildConfig` is built sequentially in the order in which they appear in the list passed to this function. NOTE: When `concurrent=False` (a sequential build), any failure encountered when executing a configuration will terminate the entire sequence. </li></ul> +| `utils.run(config_list, concurrent=true)` | <ul><li> Responsible for running build tasks on separately provisioned hosts based on a list of configuration objects passed. </li><li> Parallel builds show up in the Jenkins (Blueocean) interface under the 'Matrix' heading. </li><li> Serial builds show up in the Jenkins (Blueocean) interface under 'Serial-#' headings. </li></ul> Accepts: <ul><li> a single list of BuildConfig objects </li><li> (optional) A boolean named `concurrent` Default is `true`. When 'false', each `BuildConfig` is built sequentially in the order in which they appear in the list passed to this function. NOTE: When `concurrent=False` (a sequential build), any failure encountered when executing a configuration will terminate the entire sequence. </li></ul> | +| `utils.convert_specifiers(s)` | <ul><li> Condenses version strings by removing `.`s and replacing specifiers (`>,<,=,!,~`) with human-readable characters (`G,L,E,N,C`). </li><li> This may be used to set stage titles in a matrix containing many versions.</li><li> `def despec = utils.convert_specifiers("py3.7_np>=1.15.0_astropy>=2.0,!=2.1,<3.1.0")` produces `despec = 'py37_npGE1150_astropyGE20NE21L310'`. </li></ul> #### JobConfig Class This class contains properties that may be adjusted to control the behavior of the overall Jenkins job. diff --git a/vars/utils.groovy b/vars/utils.groovy index 5390929..7b74187 100644 --- a/vars/utils.groovy +++ b/vars/utils.groovy @@ -726,6 +726,24 @@ def run(configs, concurrent = true) { } +// Condense version triplet and replace version specifier(s) with human-readable text +// +// @param String s string containing version specifiers +// @return String string with converted version specifiers +String convert_specifiers(String s) { + String result = s + result = result.replaceAll("\\.", "") // No period + .replaceAll(",", "") // No comma + .replaceAll("<", "L") // Less than + .replaceAll(">", "G") // Greater than + .replaceAll("~=", "C") // Compatible (GE x.y && L x.*) + .replaceAll("=", "E") // Equal to (=, E | ==, EE) + .replaceAll("\\!", "N") // Not equal to + + return result +} + + // Convenience function that performs a deep copy on the supplied object. // // @param obj Java/Groovy object to copy |