View Run Condition on the plugin site for more information.
This plugin defines an ExtensionPoint that can be used by plugins to define new Run Conditions and to use Run Conditions to decide whether to run a build step.
This plugin defines a few core Run Conditions:
- Always / Never
The always and Never conditions can be used to disable a build step from the job configuration without losing the current configuration for that build step
- Boolean condition
Run the step if a token expands to a representation of true (or the string "run")
- Current status
Run the build step if the current build status is within the configured range
- File exists / Files match
Run the step if a file exists, or at least one file matches a pattern.
- Strings match
Run if the two strings are the same
- Numerical comparison
Run the build step depending on the result of comparing two numbers. Very useful with the tokens provided by the Static Code Analysis Plug-ins
- Regular expression match
Provide a regular expression and a label. The build step will run if the expression matches the label. Both the expression and the label are expanded with the Token Macro Plugin enabling a dynamic (parameterized) regex, label or both.
- Time / Day of week
Only run during a specified period of the day, or day of the week.
- And / Or / Not
Logical operations to enable the combining and sense inversion of Run Conditions
- Build Cause
Run the build step depending on the cause of the build e.g. triggered by timer, user, scm-change,...
- Script Condition
Use shell script to decide whether a step should be skipped
- Windows Batch Condition
Use windows batch to decide whether a step should be skipped
Run Conditions are currently used in the following plugins
Build Keeper Plugin —
Select a policy for automatically marking builds as "keep forever" to enable long term analysis trending when discarding old builds - or use to protect logs and artifacts from certain builds
Conditional BuildStep Plugin — A buildstep wrapping any number of other buildsteps, controlling their execution based on a defined condition.
This plugin is used by other plugins and will be installed automatically when one of those is installed from the Update Center.
To install manually, download the latest plugin from http://mirrors.jenkins-ci.org/plugins/run-condition/ and use the Upload Plugin option in the Advanced tab of the Plugin Manager.
If you do install manually, you will need to also install the Token Macro Plugin from http://mirrors.jenkins-ci.org/plugins/token-macro/.
Example: Control execution by a string parameter
... this one gets executed if 'SOME_ENV' (any environment variable) matches the string 'MyEnvValue'. As any build parameter gets exposed as an environment variable, the value can be controlled by a parameter.
Example: Run a build step if a file does not exist
Use the logical Not condition, and inside, select File exists
Example: Use a parameterised build to select which publishers to run
I.e. Set string parameter on a parameterized build to ^(UAT|DEMO)$ to run all steps that are labeled with either DEMO or UAT
Example: Only publish junit reports if we have some result files
Example: Only sound the sirens during work hours
Add an And condition and then add Time and Day of week conditions to it
Create a new Run Condition
This plugin provides an ExtensionPoint which enables other plugins to provide new Run Conditions to plugins that use them.
See the wiki page for the Run Condition Example Plugin
- fix JENKINS-14438 Build cause condition fails on matrix projects
- fix JENKINS-14584 add more information about what a condition is evaluating (there might be more conditions which need some more logging)
- implement JENKINS-19300 Allow users to run conditional build steps if the build is running on a specific node
- fix JENKINS-13853 Conditional step is not being executed by UserCause when Jenkins > 1.427
- new condition: Cause Condition
- new condition: Shell Condition
- new Condition: WindowsBatch Condition
- Fixed JENKINS-12414. Now if no result has been set, the "Current status" is SUCCESS ("Current build status" run condition)
- JENKINS-12411 Expand environment and build variables directly wherever tokens can be used
- Add a Strings match condition to test if two strings are the same
- Add a Time condition to only run during a particular time of the day
- Add a Day of week condition to only run on certain days
- Links in help files open in a new window
- Add File exists and Files match to the core conditions
- Add build step runners that enable the user to choose what happens if something goes wrong when evaluating a condition
Problems conditions may have when evaluationg - a regular expression is not valid, token expansion fails, expanded token expected to be a number, there is no spoon
- Add Boolean condition to the core run conditions
- Add Numerical comparison to the core run conditions
- Initial release