Add strings-match conditional step
Change-Id: I9a4a069b0ed4f57f0bb71a66b9bb1256d03d4f80
This commit is contained in:
parent
f9802c0a00
commit
8e96b448c4
@ -822,6 +822,12 @@ def conditional_step(parser, xml_parent, data):
|
||||
representation of true
|
||||
|
||||
:condition-expression: Expression to expand
|
||||
strings-match Run the step if two strings match
|
||||
|
||||
:condition-string1: First string
|
||||
:condition-string2: Second string
|
||||
:condition-case-insensitive: Case insensitive
|
||||
defaults to false
|
||||
current-status Run the build step if the current build status is
|
||||
within the configured range
|
||||
|
||||
@ -866,6 +872,14 @@ def conditional_step(parser, xml_parent, data):
|
||||
'org.jenkins_ci.plugins.run_condition.core.'
|
||||
'BooleanCondition')
|
||||
XML.SubElement(ctag, "token").text = cdata['condition-expression']
|
||||
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']
|
||||
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.'
|
||||
|
16
tests/builders/fixtures/conditional-step-strings-match.xml
Normal file
16
tests/builders/fixtures/conditional-step-strings-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.StringsMatchCondition">
|
||||
<arg1>my string 1</arg1>
|
||||
<arg2>my string 2</arg2>
|
||||
<ignoreCase>true</ignoreCase>
|
||||
</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: strings-match
|
||||
condition-string1: "my string 1"
|
||||
condition-string2: "my string 2"
|
||||
condition-case-insensitive: true
|
||||
steps:
|
||||
- shell: "sl"
|
Loading…
x
Reference in New Issue
Block a user