Add support for jms_messaging plugin as a trigger
- Added all the fields for JMS Messaging plugins - Added a minimal example - Added a full example Change-Id: I62906133019253a0cf391eda76b3515ecf328b9f
This commit is contained in:
parent
a5eb235881
commit
16c41b6a82
@ -777,6 +777,70 @@ def pollurl(registry, xml_parent, data):
|
||||
'ContentEntry', *content_type[0:3])
|
||||
|
||||
|
||||
def jms_messaging(registry, xml_parent, data):
|
||||
"""yaml: jms-messaging
|
||||
The JMS Messaging Plugin provides the following functionality:
|
||||
- A build trigger to submit jenkins jobs upon receipt
|
||||
of a matching message.
|
||||
- A post-build action that may be used to submit a message to the topic
|
||||
upon the completion of a job
|
||||
|
||||
JMS Messaging provider types supported:
|
||||
- ActiveMQ
|
||||
- FedMsg
|
||||
|
||||
Requires the Jenkins :jenkins-wiki:`JMS Messaging Plugin
|
||||
Pipeline Plugin <JMS+Messaging+Plugin>`.
|
||||
|
||||
:arg str selector: The JSON or YAML formatted text that conforms to
|
||||
the schema for defining the various OpenShift resources. (default '')
|
||||
note: topic needs to be in double quotes
|
||||
ex. topic = "org.fedoraproject.prod.fedimg.image.upload"
|
||||
:arg str provider-name: Name of message provider setup in the
|
||||
global config. (default '')
|
||||
:arg list checks: List of checks to monitor. (default [])
|
||||
:arg str field: Check the body of messages for a field. (default '')
|
||||
:arg str expected-value: Expected value for the field. regex (default '')
|
||||
|
||||
|
||||
Full Example:
|
||||
|
||||
.. literalinclude::
|
||||
../../tests/triggers/fixtures/jms-messaging001.yaml
|
||||
:language: yaml
|
||||
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude::
|
||||
../../tests/triggers/fixtures/jms-messaging002.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
namespace = 'com.redhat.jenkins.plugins.ci.'
|
||||
jmsm = XML.SubElement(xml_parent,
|
||||
namespace + 'CIBuildTrigger')
|
||||
|
||||
mapping = [
|
||||
# option, xml name, default value
|
||||
("spec", 'spec', ''),
|
||||
("selector", 'selector', ''),
|
||||
("provider-name", 'providerName', ''),
|
||||
]
|
||||
convert_mapping_to_xml(jmsm, data, mapping, fail_required=True)
|
||||
|
||||
checks = data.get('checks', [])
|
||||
if len(checks) > 0:
|
||||
msgchecks = XML.SubElement(jmsm, 'checks')
|
||||
for check in checks:
|
||||
msgcheck = XML.SubElement(msgchecks, namespace
|
||||
+ 'messaging.checks.MsgCheck')
|
||||
if check['field'] is '':
|
||||
raise JenkinsJobsException('At least one '
|
||||
'field must be provided')
|
||||
XML.SubElement(msgcheck, 'field').text = check['field']
|
||||
XML.SubElement(msgcheck,
|
||||
'expectedValue').text = check['expected-value']
|
||||
|
||||
|
||||
def timed(registry, xml_parent, data):
|
||||
"""yaml: timed
|
||||
Trigger builds at certain times.
|
||||
|
20
tests/triggers/fixtures/jms-messaging001.xml
Normal file
20
tests/triggers/fixtures/jms-messaging001.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<com.redhat.jenkins.plugins.ci.CIBuildTrigger>
|
||||
<spec/>
|
||||
<selector>topic = "org.fedoraproject.prod.fedimg.image.upload"</selector>
|
||||
<providerName>fedmsg</providerName>
|
||||
<checks>
|
||||
<com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck>
|
||||
<field>compose</field>
|
||||
<expectedValue>.+compose_id.+Fedora-Atomic.+</expectedValue>
|
||||
</com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck>
|
||||
<com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck>
|
||||
<field>image_name</field>
|
||||
<expectedValue>.+Fedora-Atomic.+</expectedValue>
|
||||
</com.redhat.jenkins.plugins.ci.messaging.checks.MsgCheck>
|
||||
</checks>
|
||||
</com.redhat.jenkins.plugins.ci.CIBuildTrigger>
|
||||
</triggers>
|
||||
</project>
|
9
tests/triggers/fixtures/jms-messaging001.yaml
Normal file
9
tests/triggers/fixtures/jms-messaging001.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
triggers:
|
||||
- jms-messaging:
|
||||
selector: topic = "org.fedoraproject.prod.fedimg.image.upload"
|
||||
provider-name: fedmsg
|
||||
checks:
|
||||
- field: compose
|
||||
expected-value: .+compose_id.+Fedora-Atomic.+
|
||||
- field: image_name
|
||||
expected-value: .+Fedora-Atomic.+
|
10
tests/triggers/fixtures/jms-messaging002.xml
Normal file
10
tests/triggers/fixtures/jms-messaging002.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<triggers class="vector">
|
||||
<com.redhat.jenkins.plugins.ci.CIBuildTrigger>
|
||||
<spec/>
|
||||
<selector>topic = "org.fedoraproject.prod.fedimg.image.upload"</selector>
|
||||
<providerName>fedmsg</providerName>
|
||||
</com.redhat.jenkins.plugins.ci.CIBuildTrigger>
|
||||
</triggers>
|
||||
</project>
|
5
tests/triggers/fixtures/jms-messaging002.yaml
Normal file
5
tests/triggers/fixtures/jms-messaging002.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
triggers:
|
||||
- jms-messaging:
|
||||
selector: topic = "org.fedoraproject.prod.fedimg.image.upload"
|
||||
provider-name: fedmsg
|
||||
|
Loading…
Reference in New Issue
Block a user