Support for more conditions type in conditions-buildstep plugin
Support for the following conditions - * Build cause * Day of week * Execution node * Files match * Numerical comparison * Regular expression match * Time * And * Or Change-Id: Ib65de726abf1dd4798d7dd451cd786c61c53742c
This commit is contained in:
parent
ef5edc1839
commit
85494b34c5
@ -929,83 +929,262 @@ def conditional_step(parser, xml_parent, data):
|
||||
boolean-expression Run the step if the expression expends to a
|
||||
representation of true
|
||||
|
||||
:condition-expression: Expression to expand
|
||||
:condition-expression: Expression to expand (required)
|
||||
build-cause Run if the current build has a specific cause
|
||||
|
||||
:cause: The cause why the build was triggered.
|
||||
Following causes are supported -
|
||||
|
||||
:USER_CAUSE: build was triggered by a manual
|
||||
interaction. (default)
|
||||
:SCM_CAUSE: build was triggered by a SCM change.
|
||||
:TIMER_CAUSE: build was triggered by a timer.
|
||||
:CLI_CAUSE: build was triggered by via CLI interface
|
||||
:REMOTE_CAUSE: build was triggered via remote
|
||||
interface.
|
||||
:UPSTREAM_CAUSE: build was triggered by an upstream
|
||||
project.
|
||||
|
||||
Following supported if XTrigger plugin installed:
|
||||
|
||||
:FS_CAUSE: build was triggered by a file system
|
||||
change (FSTrigger Plugin).
|
||||
:URL_CAUSE: build was triggered by a URL change
|
||||
(URLTrigger Plugin)
|
||||
:IVY_CAUSE: build triggered by an Ivy dependency
|
||||
version has change (IvyTrigger Plugin)
|
||||
:SCRIPT_CAUSE: build was triggered by a script
|
||||
(ScriptTrigger Plugin)
|
||||
:BUILDRESULT_CAUSE: build was triggered by a
|
||||
result of an other job (BuildResultTrigger Plugin)
|
||||
:exclusive-cause: (bool) There might by multiple
|
||||
casues causing a build to be triggered, with
|
||||
this true, the cause must be the only one
|
||||
causing this build this build to be triggered.
|
||||
(default False)
|
||||
day-of-week Only run on specific days of the week.
|
||||
|
||||
:day-selector: Days you want the build to run on.
|
||||
Following values are supported -
|
||||
|
||||
:weekend: Saturday and Sunday (default).
|
||||
:weekday: Monday - Friday.
|
||||
:select-days: Selected days, defined by 'days'
|
||||
below.
|
||||
:days: True for days for which the build should
|
||||
run. Definition needed only for 'select-days'
|
||||
day-selector, at the same level as day-selector.
|
||||
Define the days to run under this.
|
||||
|
||||
:SUN: Run on Sunday (default False)
|
||||
:MON: Run on Monday (default False)
|
||||
:TUES: Run on Tuesday (default False)
|
||||
:WED: Run on Wednesday (default False)
|
||||
:THURS: Run on Thursday (default False)
|
||||
:FRI: Run on Friday (default False)
|
||||
:SAT: Run on Saturday (default False)
|
||||
:use-build-time: (bool) Use the build time instead of
|
||||
the the time that the condition is evaluated.
|
||||
(default False)
|
||||
execution-node Run only on selected nodes.
|
||||
|
||||
:nodes: (list) List of nodes to execute on. (required)
|
||||
strings-match Run the step if two strings match
|
||||
|
||||
:condition-string1: First string
|
||||
:condition-string2: Second string
|
||||
:condition-string1: First string (optional)
|
||||
:condition-string2: Second string (optional)
|
||||
:condition-case-insensitive: Case insensitive
|
||||
defaults to false
|
||||
(default False)
|
||||
current-status Run the build step if the current build status is
|
||||
within the configured range
|
||||
|
||||
:condition-worst: Accepted values are SUCCESS,
|
||||
UNSTABLE, FAILURE, NOT_BUILD, ABORTED
|
||||
(default SUCCESS)
|
||||
:condition-best: Accepted values are SUCCESS,
|
||||
UNSTABLE, FAILURE, NOT_BUILD, ABORTED
|
||||
(default SUCCESS)
|
||||
|
||||
shell Run the step if the shell command succeed
|
||||
|
||||
:condition-command: Shell command to execute
|
||||
(optional)
|
||||
windows-shell Similar to shell, except that commands will be
|
||||
executed by cmd, under Windows
|
||||
|
||||
:condition-command: Command to execute
|
||||
:condition-command: Command to execute (optional)
|
||||
file-exists Run the step if a file exists
|
||||
|
||||
:condition-filename: Check existence of this file
|
||||
(required)
|
||||
:condition-basedir: If condition-filename is
|
||||
relative, it will be considered relative to
|
||||
either `workspace`, `artifact-directory`,
|
||||
or `jenkins-home`. Default is `workspace`.
|
||||
or `jenkins-home`. (default 'workspace')
|
||||
files-match Run if one or more files match the selectors.
|
||||
|
||||
:include-pattern: (list str) List of Includes
|
||||
Patterns. Since the separator in the patterns is
|
||||
hardcoded as ',', any use of ',' would need
|
||||
escaping. (optional)
|
||||
:exclude-pattern: (list str) List of Excludes
|
||||
Patterns. Since the separator in the patterns is
|
||||
hardcoded as ',', any use of ',' would need
|
||||
escaping. (optional)
|
||||
:condition-basedir: Accepted values are `workspace`,
|
||||
`artifact-directory`, or `jenkins-home`.
|
||||
(default 'workspace')
|
||||
num-comp Run if the numerical comparison is true.
|
||||
|
||||
:lhs: Left Hand Side. Must evaluate to a number.
|
||||
(required)
|
||||
:rhs: Right Hand Side. Must evaluate to a number.
|
||||
(required)
|
||||
:comparator: Accepted values are `less-than`,
|
||||
`greater-than`, `equal`, `not-equal`,
|
||||
`less-than-equal`, `greater-than-equal`.
|
||||
(default 'less-than')
|
||||
regex-match Run if the Expression matches the Label.
|
||||
|
||||
:regex: The regular expression used to match the label
|
||||
(optional)
|
||||
:label: The label that will be tested by the regular
|
||||
expression. (optional)
|
||||
time Only run during a certain period of the day.
|
||||
|
||||
:earliest-hour: Starting hour (default "09")
|
||||
:earliest-min: Starting min (default "00")
|
||||
:latest-hour: Ending hour (default "17")
|
||||
:latest-min: Ending min (default "30")
|
||||
:use-build-time: (bool) Use the build time instead of
|
||||
the the time that the condition is evaluated.
|
||||
(default False)
|
||||
not Run the step if the inverse of the condition-operand
|
||||
is true
|
||||
|
||||
:condition-operand: Condition to evaluate. Can be
|
||||
any supported conditional-step condition.
|
||||
any supported conditional-step condition. (required)
|
||||
and Run the step if logical and of all conditional-operands
|
||||
is true
|
||||
|
||||
:condition-operands: (list) Conditions to evaluate.
|
||||
Can be any supported conditional-step condition.
|
||||
(required)
|
||||
or Run the step if logical or of all conditional-operands
|
||||
is true
|
||||
|
||||
:condition-operands: (list) Conditions to evaluate.
|
||||
Can be any supported conditional-step condition.
|
||||
(required)
|
||||
================== ====================================================
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: \
|
||||
/../../tests/builders/fixtures/conditional-step-success-failure.yaml
|
||||
:language: yaml
|
||||
.. literalinclude:: \
|
||||
/../../tests/builders/fixtures/conditional-step-not-file-exists.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-success-failure.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-not-file-exists.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-day-of-week001.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-day-of-week003.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-time.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-regex-match.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-or.yaml
|
||||
:language: yaml
|
||||
.. literalinclude::
|
||||
/../../tests/builders/fixtures/conditional-step-and.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
def build_condition(cdata, cond_root_tag):
|
||||
kind = cdata['condition-kind']
|
||||
ctag = XML.SubElement(cond_root_tag, condition_tag)
|
||||
core_prefix = 'org.jenkins_ci.plugins.run_condition.core.'
|
||||
logic_prefix = 'org.jenkins_ci.plugins.run_condition.logic.'
|
||||
if kind == "always":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.core.AlwaysRun')
|
||||
ctag.set('class', core_prefix + 'AlwaysRun')
|
||||
elif kind == "never":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.core.NeverRun')
|
||||
ctag.set('class', core_prefix + 'NeverRun')
|
||||
elif kind == "boolean-expression":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.core.'
|
||||
'BooleanCondition')
|
||||
XML.SubElement(ctag, "token").text = cdata['condition-expression']
|
||||
ctag.set('class', core_prefix + 'BooleanCondition')
|
||||
try:
|
||||
XML.SubElement(ctag, "token").text = \
|
||||
cdata['condition-expression']
|
||||
except KeyError:
|
||||
raise MissingAttributeError('condition-expression')
|
||||
elif kind == "build-cause":
|
||||
ctag.set('class', core_prefix + 'CauseCondition')
|
||||
cause_list = ('USER_CAUSE', 'SCM_CAUSE', 'TIMER_CAUSE',
|
||||
'CLI_CAUSE', 'REMOTE_CAUSE', 'UPSTREAM_CAUSE',
|
||||
'FS_CAUSE', 'URL_CAUSE', 'IVY_CAUSE',
|
||||
'SCRIPT_CAUSE', 'BUILDRESULT_CAUSE')
|
||||
cause_name = cdata.get('cause', 'USER_CAUSE')
|
||||
if cause_name not in cause_list:
|
||||
raise InvalidAttributeError('cause', cause_name, cause_list)
|
||||
XML.SubElement(ctag, "buildCause").text = cause_name
|
||||
XML.SubElement(ctag, "exclusiveCause").text = str(cdata.get(
|
||||
'exclusive-cause', False)).lower()
|
||||
elif kind == "day-of-week":
|
||||
ctag.set('class', core_prefix + 'DayCondition')
|
||||
day_selector_class_prefix = core_prefix + 'DayCondition$'
|
||||
day_selector_classes = {
|
||||
'weekend': day_selector_class_prefix + 'Weekend',
|
||||
'weekday': day_selector_class_prefix + 'Weekday',
|
||||
'select-days': day_selector_class_prefix + 'SelectDays',
|
||||
}
|
||||
day_selector = cdata.get('day-selector', 'weekend')
|
||||
if day_selector not in day_selector_classes:
|
||||
raise InvalidAttributeError('day-selector', day_selector,
|
||||
day_selector_classes)
|
||||
day_selector_tag = XML.SubElement(ctag, "daySelector")
|
||||
day_selector_tag.set('class', day_selector_classes[day_selector])
|
||||
if day_selector == "select-days":
|
||||
days_tag = XML.SubElement(day_selector_tag, "days")
|
||||
day_tag_text = ('org.jenkins__ci.plugins.run__condition.'
|
||||
'core.DayCondition_-Day')
|
||||
inp_days = cdata.get('days') if cdata.get('days') else {}
|
||||
days = ['SUN', 'MON', 'TUES', 'WED', 'THURS', 'FRI', 'SAT']
|
||||
for day_no, day in enumerate(days, 1):
|
||||
day_tag = XML.SubElement(days_tag, day_tag_text)
|
||||
XML.SubElement(day_tag, "day").text = str(day_no)
|
||||
XML.SubElement(day_tag, "selected").text = str(
|
||||
inp_days.get(day, False)).lower()
|
||||
XML.SubElement(ctag, "useBuildTime").text = str(cdata.get(
|
||||
'use-build-time', False)).lower()
|
||||
elif kind == "execution-node":
|
||||
ctag.set('class', core_prefix + 'NodeCondition')
|
||||
allowed_nodes_tag = XML.SubElement(ctag, "allowedNodes")
|
||||
try:
|
||||
nodes_list = cdata['nodes']
|
||||
except KeyError:
|
||||
raise MissingAttributeError('nodes')
|
||||
for node in nodes_list:
|
||||
node_tag = XML.SubElement(allowed_nodes_tag, "string")
|
||||
node_tag.text = node
|
||||
elif kind == "strings-match":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.core.'
|
||||
'StringsMatchCondition')
|
||||
XML.SubElement(ctag, "arg1").text = cdata['condition-string1']
|
||||
XML.SubElement(ctag, "arg2").text = cdata['condition-string2']
|
||||
ctag.set('class', core_prefix + 'StringsMatchCondition')
|
||||
XML.SubElement(ctag, "arg1").text = cdata.get(
|
||||
'condition-string1', '')
|
||||
XML.SubElement(ctag, "arg2").text = cdata.get(
|
||||
'condition-string2', '')
|
||||
XML.SubElement(ctag, "ignoreCase").text = str(cdata.get(
|
||||
'condition-case-insensitive', False)).lower()
|
||||
elif kind == "current-status":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.core.'
|
||||
'StatusCondition')
|
||||
ctag.set('class', core_prefix + 'StatusCondition')
|
||||
wr = XML.SubElement(ctag, 'worstResult')
|
||||
wr_name = cdata['condition-worst']
|
||||
wr_name = cdata.get('condition-worst', 'SUCCESS')
|
||||
if wr_name not in hudson_model.THRESHOLDS:
|
||||
raise JenkinsJobsException(
|
||||
"threshold must be one of %s" %
|
||||
", ".join(hudson_model.THRESHOLDS.keys()))
|
||||
raise InvalidAttributeError('condition-worst', wr_name,
|
||||
hudson_model.THRESHOLDS.keys())
|
||||
wr_threshold = hudson_model.THRESHOLDS[wr_name]
|
||||
XML.SubElement(wr, "name").text = wr_threshold['name']
|
||||
XML.SubElement(wr, "ordinal").text = wr_threshold['ordinal']
|
||||
@ -1014,11 +1193,10 @@ def conditional_step(parser, xml_parent, data):
|
||||
str(wr_threshold['complete']).lower()
|
||||
|
||||
br = XML.SubElement(ctag, 'bestResult')
|
||||
br_name = cdata['condition-best']
|
||||
br_name = cdata.get('condition-best', 'SUCCESS')
|
||||
if br_name not in hudson_model.THRESHOLDS:
|
||||
raise JenkinsJobsException(
|
||||
"threshold must be one of %s" %
|
||||
", ".join(hudson_model.THRESHOLDS.keys()))
|
||||
raise InvalidAttributeError('condition-best', br_name,
|
||||
hudson_model.THRESHOLDS.keys())
|
||||
br_threshold = hudson_model.THRESHOLDS[br_name]
|
||||
XML.SubElement(br, "name").text = br_threshold['name']
|
||||
XML.SubElement(br, "ordinal").text = br_threshold['ordinal']
|
||||
@ -1029,36 +1207,102 @@ def conditional_step(parser, xml_parent, data):
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.contributed.'
|
||||
'ShellCondition')
|
||||
XML.SubElement(ctag, "command").text = cdata['condition-command']
|
||||
XML.SubElement(ctag, "command").text = cdata.get(
|
||||
'condition-command', '')
|
||||
elif kind == "windows-shell":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.contributed.'
|
||||
'BatchFileCondition')
|
||||
XML.SubElement(ctag, "command").text = cdata['condition-command']
|
||||
elif kind == "file-exists":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.core.'
|
||||
'FileExistsCondition')
|
||||
XML.SubElement(ctag, "file").text = cdata['condition-filename']
|
||||
XML.SubElement(ctag, "command").text = cdata.get(
|
||||
'condition-command', '')
|
||||
elif kind == "file-exists" or kind == "files-match":
|
||||
if kind == "file-exists":
|
||||
ctag.set('class', core_prefix + 'FileExistsCondition')
|
||||
try:
|
||||
XML.SubElement(ctag, "file").text = \
|
||||
cdata['condition-filename']
|
||||
except KeyError:
|
||||
raise MissingAttributeError('condition-filename')
|
||||
else:
|
||||
ctag.set('class', core_prefix + 'FilesMatchCondition')
|
||||
XML.SubElement(ctag, "includes").text = ",".join(cdata.get(
|
||||
'include-pattern', ''))
|
||||
XML.SubElement(ctag, "excludes").text = ",".join(cdata.get(
|
||||
'exclude-pattern', ''))
|
||||
basedir_class_prefix = ('org.jenkins_ci.plugins.run_condition.'
|
||||
'common.BaseDirectory$')
|
||||
basedir_classes = {
|
||||
'workspace': basedir_class_prefix + 'Workspace',
|
||||
'artifact-directory': basedir_class_prefix + 'ArtifactsDir',
|
||||
'jenkins-home': basedir_class_prefix + 'JenkinsHome'
|
||||
}
|
||||
basedir = cdata.get('condition-basedir', 'workspace')
|
||||
basedir_tag = XML.SubElement(ctag, "baseDir")
|
||||
if "workspace" == basedir:
|
||||
basedir_tag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.common.'
|
||||
'BaseDirectory$Workspace')
|
||||
elif "artifact-directory" == basedir:
|
||||
basedir_tag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.common.'
|
||||
'BaseDirectory$ArtifactsDir')
|
||||
elif "jenkins-home" == basedir:
|
||||
basedir_tag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.common.'
|
||||
'BaseDirectory$JenkinsHome')
|
||||
if basedir not in basedir_classes:
|
||||
raise InvalidAttributeError('condition-basedir', basedir,
|
||||
basedir_classes)
|
||||
XML.SubElement(ctag, "baseDir").set('class',
|
||||
basedir_classes[basedir])
|
||||
elif kind == "num-comp":
|
||||
ctag.set('class', core_prefix + 'NumericalComparisonCondition')
|
||||
try:
|
||||
XML.SubElement(ctag, "lhs").text = cdata['lhs']
|
||||
XML.SubElement(ctag, "rhs").text = cdata['rhs']
|
||||
except KeyError as e:
|
||||
raise MissingAttributeError(e.args[0])
|
||||
comp_class_prefix = core_prefix + 'NumericalComparisonCondition$'
|
||||
comp_classes = {
|
||||
'less-than': comp_class_prefix + 'LessThan',
|
||||
'greater-than': comp_class_prefix + 'GreaterThan',
|
||||
'equal': comp_class_prefix + 'EqualTo',
|
||||
'not-equal': comp_class_prefix + 'NotEqualTo',
|
||||
'less-than-equal': comp_class_prefix + 'LessThanOrEqualTo',
|
||||
'greater-than-equal': comp_class_prefix +
|
||||
'GreaterThanOrEqualTo'
|
||||
}
|
||||
comp = cdata.get('comparator', 'less-than')
|
||||
if comp not in comp_classes:
|
||||
raise InvalidAttributeError('comparator', comp, comp_classes)
|
||||
XML.SubElement(ctag, "comparator").set('class',
|
||||
comp_classes[comp])
|
||||
elif kind == "regex-match":
|
||||
ctag.set('class', core_prefix + 'ExpressionCondition')
|
||||
XML.SubElement(ctag, "expression").text = cdata.get('regex', '')
|
||||
XML.SubElement(ctag, "label").text = cdata.get('label', '')
|
||||
elif kind == "time":
|
||||
ctag.set('class', core_prefix + 'TimeCondition')
|
||||
XML.SubElement(ctag, "earliestHours").text = cdata.get(
|
||||
'earliest-hour', '09')
|
||||
XML.SubElement(ctag, "earliestMinutes").text = cdata.get(
|
||||
'earliest-min', '00')
|
||||
XML.SubElement(ctag, "latestHours").text = cdata.get(
|
||||
'latest-hour', '17')
|
||||
XML.SubElement(ctag, "latestMinutes").text = cdata.get(
|
||||
'latest-min', '30')
|
||||
XML.SubElement(ctag, "useBuildTime").text = str(cdata.get(
|
||||
'use-build-time', False)).lower()
|
||||
elif kind == "not":
|
||||
ctag.set('class',
|
||||
'org.jenkins_ci.plugins.run_condition.logic.Not')
|
||||
notcondition = cdata['condition-operand']
|
||||
ctag.set('class', logic_prefix + 'Not')
|
||||
try:
|
||||
notcondition = cdata['condition-operand']
|
||||
except KeyError:
|
||||
raise MissingAttributeError('condition-operand')
|
||||
build_condition(notcondition, ctag)
|
||||
elif kind == "and" or "or":
|
||||
if kind == "and":
|
||||
ctag.set('class', logic_prefix + 'And')
|
||||
else:
|
||||
ctag.set('class', logic_prefix + 'Or')
|
||||
conditions_tag = XML.SubElement(ctag, "conditions")
|
||||
container_tag_text = ('org.jenkins__ci.plugins.run__condition.'
|
||||
'logic.ConditionContainer')
|
||||
try:
|
||||
conditions_list = cdata['condition-operands']
|
||||
except KeyError:
|
||||
raise MissingAttributeError('condition-operands')
|
||||
for condition in conditions_list:
|
||||
conditions_container_tag = XML.SubElement(conditions_tag,
|
||||
container_tag_text)
|
||||
build_condition(condition, conditions_container_tag)
|
||||
|
||||
def build_step(parent, step):
|
||||
for edited_node in create_builders(parser, step):
|
||||
|
30
tests/builders/fixtures/conditional-step-and.xml
Normal file
30
tests/builders/fixtures/conditional-step-and.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.logic.And">
|
||||
<conditions>
|
||||
<org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.ExpressionCondition">
|
||||
<expression>*abc*</expression>
|
||||
<label>dabcddabc</label>
|
||||
</condition>
|
||||
</org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
<org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.TimeCondition">
|
||||
<earliestHours>2</earliestHours>
|
||||
<earliestMinutes>0</earliestMinutes>
|
||||
<latestHours>23</latestHours>
|
||||
<latestMinutes>40</latestMinutes>
|
||||
<useBuildTime>true</useBuildTime>
|
||||
</condition>
|
||||
</org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
</conditions>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
16
tests/builders/fixtures/conditional-step-and.yaml
Normal file
16
tests/builders/fixtures/conditional-step-and.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: and
|
||||
condition-operands:
|
||||
- condition-kind: regex-match
|
||||
regex: "*abc*"
|
||||
label: "dabcddabc"
|
||||
- condition-kind: time
|
||||
earliest-hour: "2"
|
||||
earliest-min: "0"
|
||||
latest-hour: "23"
|
||||
latest-min: "40"
|
||||
use-build-time: true
|
||||
steps:
|
||||
- shell: "sl"
|
||||
|
15
tests/builders/fixtures/conditional-step-build-cause.xml
Normal file
15
tests/builders/fixtures/conditional-step-build-cause.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.CauseCondition">
|
||||
<buildCause>SCM_CAUSE</buildCause>
|
||||
<exclusiveCause>true</exclusiveCause>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: build-cause
|
||||
cause: SCM_CAUSE
|
||||
exclusive-cause: true
|
||||
steps:
|
||||
- shell: "sl"
|
15
tests/builders/fixtures/conditional-step-day-of-week001.xml
Normal file
15
tests/builders/fixtures/conditional-step-day-of-week001.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.DayCondition">
|
||||
<daySelector class="org.jenkins_ci.plugins.run_condition.core.DayCondition$Weekday"/>
|
||||
<useBuildTime>true</useBuildTime>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: day-of-week
|
||||
day-selector: weekday
|
||||
use-build-time: true
|
||||
steps:
|
||||
- shell: "sl"
|
46
tests/builders/fixtures/conditional-step-day-of-week002.xml
Normal file
46
tests/builders/fixtures/conditional-step-day-of-week002.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.DayCondition">
|
||||
<daySelector class="org.jenkins_ci.plugins.run_condition.core.DayCondition$SelectDays">
|
||||
<days>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>1</day>
|
||||
<selected>true</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>2</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>3</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>4</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>5</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>6</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>7</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
</days>
|
||||
</daySelector>
|
||||
<useBuildTime>true</useBuildTime>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,9 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: day-of-week
|
||||
day-selector: select-days
|
||||
days:
|
||||
SUN: true
|
||||
use-build-time: true
|
||||
steps:
|
||||
- shell: "sl"
|
46
tests/builders/fixtures/conditional-step-day-of-week003.xml
Normal file
46
tests/builders/fixtures/conditional-step-day-of-week003.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.DayCondition">
|
||||
<daySelector class="org.jenkins_ci.plugins.run_condition.core.DayCondition$SelectDays">
|
||||
<days>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>1</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>2</day>
|
||||
<selected>true</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>3</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>4</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>5</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>6</day>
|
||||
<selected>true</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
<day>7</day>
|
||||
<selected>false</selected>
|
||||
</org.jenkins__ci.plugins.run__condition.core.DayCondition_-Day>
|
||||
</days>
|
||||
</daySelector>
|
||||
<useBuildTime>true</useBuildTime>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
10
tests/builders/fixtures/conditional-step-day-of-week003.yaml
Normal file
10
tests/builders/fixtures/conditional-step-day-of-week003.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: day-of-week
|
||||
day-selector: select-days
|
||||
days:
|
||||
MON: true
|
||||
FRI: true
|
||||
use-build-time: true
|
||||
steps:
|
||||
- shell: "sl"
|
17
tests/builders/fixtures/conditional-step-execution-node.xml
Normal file
17
tests/builders/fixtures/conditional-step-execution-node.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.NodeCondition">
|
||||
<allowedNodes>
|
||||
<string>master</string>
|
||||
<string>master2</string>
|
||||
</allowedNodes>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: execution-node
|
||||
nodes:
|
||||
- "master"
|
||||
- "master2"
|
||||
steps:
|
||||
- shell: "sl"
|
16
tests/builders/fixtures/conditional-step-files-match.xml
Normal file
16
tests/builders/fixtures/conditional-step-files-match.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.FilesMatchCondition">
|
||||
<includes>inc_pattern1,inc_pattern2</includes>
|
||||
<excludes>exc_pattern1,exc_pattern2</excludes>
|
||||
<baseDir class="org.jenkins_ci.plugins.run_condition.common.BaseDirectory$JenkinsHome"/>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
12
tests/builders/fixtures/conditional-step-files-match.yaml
Normal file
12
tests/builders/fixtures/conditional-step-files-match.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: files-match
|
||||
include-pattern:
|
||||
- "inc_pattern1"
|
||||
- "inc_pattern2"
|
||||
exclude-pattern:
|
||||
- "exc_pattern1"
|
||||
- "exc_pattern2"
|
||||
condition-basedir: "jenkins-home"
|
||||
steps:
|
||||
- shell: "sl"
|
16
tests/builders/fixtures/conditional-step-num-comp.xml
Normal file
16
tests/builders/fixtures/conditional-step-num-comp.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.NumericalComparisonCondition">
|
||||
<lhs>2 + 5</lhs>
|
||||
<rhs>1 + 6</rhs>
|
||||
<comparator class="org.jenkins_ci.plugins.run_condition.core.NumericalComparisonCondition$EqualTo"/>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
9
tests/builders/fixtures/conditional-step-num-comp.yaml
Normal file
9
tests/builders/fixtures/conditional-step-num-comp.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: num-comp
|
||||
lhs: "2 + 5"
|
||||
rhs: "1 + 6"
|
||||
comparator: equal
|
||||
condition-basedir: "jenkins-home"
|
||||
steps:
|
||||
- shell: "sl"
|
29
tests/builders/fixtures/conditional-step-or.xml
Normal file
29
tests/builders/fixtures/conditional-step-or.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.logic.Or">
|
||||
<conditions>
|
||||
<org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.NumericalComparisonCondition">
|
||||
<lhs>2 + 5</lhs>
|
||||
<rhs>1 + 6</rhs>
|
||||
<comparator class="org.jenkins_ci.plugins.run_condition.core.NumericalComparisonCondition$EqualTo"/>
|
||||
</condition>
|
||||
</org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
<org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.FilesMatchCondition">
|
||||
<includes>inc_pattern1,inc_pattern2</includes>
|
||||
<excludes>exc_pattern1,exc_pattern2</excludes>
|
||||
<baseDir class="org.jenkins_ci.plugins.run_condition.common.BaseDirectory$JenkinsHome"/>
|
||||
</condition>
|
||||
</org.jenkins__ci.plugins.run__condition.logic.ConditionContainer>
|
||||
</conditions>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
20
tests/builders/fixtures/conditional-step-or.yaml
Normal file
20
tests/builders/fixtures/conditional-step-or.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: or
|
||||
condition-operands:
|
||||
- condition-kind: num-comp
|
||||
lhs: "2 + 5"
|
||||
rhs: "1 + 6"
|
||||
comparator: equal
|
||||
condition-basedir: "jenkins-home"
|
||||
- condition-kind: files-match
|
||||
include-pattern:
|
||||
- "inc_pattern1"
|
||||
- "inc_pattern2"
|
||||
exclude-pattern:
|
||||
- "exc_pattern1"
|
||||
- "exc_pattern2"
|
||||
condition-basedir: "jenkins-home"
|
||||
steps:
|
||||
- shell: "sl"
|
||||
|
15
tests/builders/fixtures/conditional-step-regex-match.xml
Normal file
15
tests/builders/fixtures/conditional-step-regex-match.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.ExpressionCondition">
|
||||
<expression>a*b</expression>
|
||||
<label>cadaaab</label>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: regex-match
|
||||
regex: a*b
|
||||
label: cadaaab
|
||||
steps:
|
||||
- shell: "sl"
|
18
tests/builders/fixtures/conditional-step-time.xml
Normal file
18
tests/builders/fixtures/conditional-step-time.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
<condition class="org.jenkins_ci.plugins.run_condition.core.TimeCondition">
|
||||
<earliestHours>4</earliestHours>
|
||||
<earliestMinutes>15</earliestMinutes>
|
||||
<latestHours>20</latestHours>
|
||||
<latestMinutes>30</latestMinutes>
|
||||
<useBuildTime>false</useBuildTime>
|
||||
</condition>
|
||||
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||
<buildStep class="hudson.tasks.Shell">
|
||||
<command>sl</command>
|
||||
</buildStep>
|
||||
</org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder>
|
||||
</builders>
|
||||
</project>
|
9
tests/builders/fixtures/conditional-step-time.yaml
Normal file
9
tests/builders/fixtures/conditional-step-time.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
builders:
|
||||
- conditional-step:
|
||||
condition-kind: time
|
||||
earliest-hour: "4"
|
||||
earliest-min: "15"
|
||||
latest-hour: "20"
|
||||
latest-min: "30"
|
||||
steps:
|
||||
- shell: "sl"
|
Loading…
Reference in New Issue
Block a user