Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Regex in bot commands (cb, q)

...

  • status: displays the status of the build i.e. last build result and last successful build
  • health: displays the build health as computed from the last build results, test results, (compiler warnings, findbugs warnings, ...)
  • build: schedules a new build of a job
  • abort: aborts a currently running build
  • currentlyBuilding (or cb): list the jobs that are actively in progress, with optional regex filtering of output; you can also pass a @ argument to get URLs to the build's console log in the chat
  • queue (or q): list the jobs that are actively in progress, with optional regex filtering of output
  • help: gets a list of all available commands

Regex support in bot commands

The currentlyBuilding (cb) and queue (q) commands now support an optional argument to apply regular expression filters to the lines they would output, and count and report hits compared to the full job lists.

The key argument for this is ~ and the rest of the argument string is assumed to be the regular expression (note however that whitespace between tokens of the argument string is converted during argument processing; for clarity it would be preferable to pass a single-token argument with \s+ in positions where whitespace matches are expected).

For example, to see any "OVA"-related builds in IRC I would type:

Code Block
(15:07:34) developer: jenkins: cb @ ~ OVA
(15:07:34) jenkins: (notice) Currently building (10 items total, of which 1 items matched the filter):
(15:07:34) jenkins: (notice) - NOTE: got @ argument for currentlyBuilding: will add URLs to reported strings
(15:07:35) jenkins: (notice) - NOTE: got ~ filtering argument for currentlyBuilding: applying regex filter to reported strings: OVA
(15:07:35) jenkins: (notice) - ova-build-machine-1#0: build-OVA-image #5939 @ https://jenkins.localdomain/job/build-OVA-image/5939/console (Elapsed time: 1 min 0 sec, Estimated remaining time: 3 min 58 sec)

Beside ordinarily matching what is present in a line, this can be used with "negative lookups" for matching lines that do not contain certain patterns. Certain know-how applies to such expressions:

  • To negative-match the whole string from start, use a caret, e.g.: 

    Code Block
    cb ~ ^(?!master)

    to skip jobs running on nodes whose name starts with (or equals) master. Without the caret it did not work.

  • For matching inside a job name, the .* must be also inside the lookahead pattern: 

    Code Block
    cb ~ ^(?!.*rescan)

    would list only jobs whose IM report line does NOT include rescan.

Issues/Gotchas

  • This plugin serializes all builds for a job which is configured with the Execute concurrent builds option. Means: build n will never finish before build n+1. Build n+1 will always wait until n finishes - even if n+1 would have finished long before n. This is required because the plugin needs to determine the build result trend  (e.g. for FIXED, STILL FAILING, STILL UNSTABLE) for the notifications.

...