diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index 9194e948a..3d3deb079 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -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.' diff --git a/tests/builders/fixtures/conditional-step-strings-match.xml b/tests/builders/fixtures/conditional-step-strings-match.xml new file mode 100644 index 000000000..5c50908bb --- /dev/null +++ b/tests/builders/fixtures/conditional-step-strings-match.xml @@ -0,0 +1,16 @@ + + + + + + my string 1 + my string 2 + true + + + + sl + + + + diff --git a/tests/builders/fixtures/conditional-step-strings-match.yaml b/tests/builders/fixtures/conditional-step-strings-match.yaml new file mode 100644 index 000000000..d9559c08b --- /dev/null +++ b/tests/builders/fixtures/conditional-step-strings-match.yaml @@ -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"