diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index c8b8d7ba2..c3cdbbca8 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -4287,6 +4287,11 @@ def conditional_publisher(parser, xml_parent, data): executed by cmd, under Windows :condition-command: Command to execute + regexp Run the action if a regular expression matches + + :condition-expression: Regular Expression + :condition-searchtext: Text to match against + the regular expression file-exists Run the action if a file exists :condition-filename: Check existence of this file @@ -4365,6 +4370,12 @@ def conditional_publisher(parser, xml_parent, data): ctag.set('class', class_pkg + '.contributed.BatchFileCondition') XML.SubElement(ctag, "command").text = cdata['condition-command'] + elif kind == "regexp": + ctag.set('class', + class_pkg + '.core.ExpressionCondition') + XML.SubElement(ctag, + "expression").text = cdata['condition-expression'] + XML.SubElement(ctag, "label").text = cdata['condition-searchtext'] elif kind == "file-exists": ctag.set('class', class_pkg + '.core.FileExistsCondition') diff --git a/tests/publishers/fixtures/conditional-publisher004.xml b/tests/publishers/fixtures/conditional-publisher004.xml new file mode 100644 index 000000000..773cb4c6f --- /dev/null +++ b/tests/publishers/fixtures/conditional-publisher004.xml @@ -0,0 +1,21 @@ + + + + + + + + ^(origin\/)?master$ + + + + + **/** + false + true + + + + + + diff --git a/tests/publishers/fixtures/conditional-publisher004.yaml b/tests/publishers/fixtures/conditional-publisher004.yaml new file mode 100644 index 000000000..a1e5117c9 --- /dev/null +++ b/tests/publishers/fixtures/conditional-publisher004.yaml @@ -0,0 +1,10 @@ +publishers: + - conditional-publisher: + - condition-kind: regexp + condition-expression: ^(origin\/)?master$ + condition-searchtext: $GIT_BRANCH + action: + - archive: + artifacts: '**/**' + allow-empty: 'true' +