Add regexp option to conditional publisher
Allows for use of regular expression conditions in the conditional publisher plugin. Exposes two new fields: condition-expression and condition-searchtext. Change-Id: Ib752d686f009ca5687956622e22ee466c6791695
This commit is contained in:
parent
3daf621c1f
commit
d8d003514b
@ -4287,6 +4287,11 @@ def conditional_publisher(parser, xml_parent, data):
|
|||||||
executed by cmd, under Windows
|
executed by cmd, under Windows
|
||||||
|
|
||||||
:condition-command: Command to execute
|
: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
|
file-exists Run the action if a file exists
|
||||||
|
|
||||||
:condition-filename: Check existence of this file
|
:condition-filename: Check existence of this file
|
||||||
@ -4365,6 +4370,12 @@ def conditional_publisher(parser, xml_parent, data):
|
|||||||
ctag.set('class',
|
ctag.set('class',
|
||||||
class_pkg + '.contributed.BatchFileCondition')
|
class_pkg + '.contributed.BatchFileCondition')
|
||||||
XML.SubElement(ctag, "command").text = cdata['condition-command']
|
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":
|
elif kind == "file-exists":
|
||||||
ctag.set('class',
|
ctag.set('class',
|
||||||
class_pkg + '.core.FileExistsCondition')
|
class_pkg + '.core.FileExistsCondition')
|
||||||
|
21
tests/publishers/fixtures/conditional-publisher004.xml
Normal file
21
tests/publishers/fixtures/conditional-publisher004.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<org.jenkins__ci.plugins.flexible__publish.FlexiblePublisher>
|
||||||
|
<publishers>
|
||||||
|
<org.jenkins__ci.plugins.flexible__publish.ConditionalPublisher>
|
||||||
|
<condition class="org.jenkins_ci.plugins.run_condition.core.ExpressionCondition">
|
||||||
|
<expression>^(origin\/)?master$</expression>
|
||||||
|
<label>$GIT_BRANCH</label>
|
||||||
|
</condition>
|
||||||
|
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
|
||||||
|
<publisher class="hudson.tasks.ArtifactArchiver">
|
||||||
|
<artifacts>**/**</artifacts>
|
||||||
|
<latestOnly>false</latestOnly>
|
||||||
|
<allowEmptyArchive>true</allowEmptyArchive>
|
||||||
|
</publisher>
|
||||||
|
</org.jenkins__ci.plugins.flexible__publish.ConditionalPublisher>
|
||||||
|
</publishers>
|
||||||
|
</org.jenkins__ci.plugins.flexible__publish.FlexiblePublisher>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
10
tests/publishers/fixtures/conditional-publisher004.yaml
Normal file
10
tests/publishers/fixtures/conditional-publisher004.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
publishers:
|
||||||
|
- conditional-publisher:
|
||||||
|
- condition-kind: regexp
|
||||||
|
condition-expression: ^(origin\/)?master$
|
||||||
|
condition-searchtext: $GIT_BRANCH
|
||||||
|
action:
|
||||||
|
- archive:
|
||||||
|
artifacts: '**/**'
|
||||||
|
allow-empty: 'true'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user